0

I have installed the latest version of Python on my CentOS 6.9 using the root user and this has been successful. I have basically run the following commands;

wget http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
strip /usr/local/lib/libpython3.6m.so.1.0
wget https://bootstrap.pypa.io/get-pip.py
python3.6 get-pip.py

This has worked. I have exited the root login via ssh and have logged in with another Cpanel user to try and install and run a django app. I have created and activated a virtualenv by running this;

mkdir myproject
cd myproject
virtualenv mydjangoproject
source mydjangoproject/bin/activate

Now I am trying to install Django in my virtualenv using Python3.6 When I run this;

pip3.6 install django

I get the following error;

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/usr/local/lib/python3.6/site-packages/pytz-2017.2.dist-info'

I am quite new to this so I am assuming a file cannot be created in /usr/local/lib/python3.6/ since I am not logged in as root. But I want to install the Django package in my virtualenv which makes sense since when a new version comes out I don't have to worry about using a global Django version.

  • You may have created your virtualenv with the wrong Python. What do the commands `which python`, `which pip`, `python --version`, and `pip --version` give after you have done `source mydjangoproject/bin/activate`? (The immediate problem is probably the use of the `pip3.6` command instead of simply `pip`, but we can deal with that in a moment.) – ChrisGPT was on strike Aug 07 '17 at 22:38
  • 1
    Once you activate the virtualenv just use pip http://imgur.com/a/zOAP5 – diek Aug 07 '17 at 23:43
  • @diek Yes I did that. I did `python3.6 -m venv env` to make sure that the virtual environment is created with python3.6. But before doing this I made a mistake of first installing Django `pip install django` using the root user. So now when I try to install Django in my virtual env I get; `Requirement already satisfied: django in ./env/lib/python3.6/site-packages` and `Requirement already satisfied: pytz in ./env/lib/python3.6/site-packages (from django)` So I suppose this means Django is installed in my virtual env. I don't know how that happened. –  Aug 08 '17 at 00:58
  • Remove the sys install of Django `pip uninstall django` – diek Aug 08 '17 at 01:08
  • `Cannot uninstall requirement django, not installed` I probably installed it in my virtual env before not globally. –  Aug 08 '17 at 01:29

0 Answers0