scl, virtualenvwrapper and python3
This is where I will finally get to the bottom of how to get virtualenvwrapper to work nicely for me with python3 installed via an SCL (software collection) on CentOS7. Probably I should just get used to using pyvenv for python3 instead of mucking about with virtualenv, but I would like to understand how to make this work.
So far the best resources look like these:
http://developers.redhat.com/blog/2014/02/27/using-pythons-virtualenv-with-rhscl/
https://www.softwarecollections.org/en/docs/
https://sopel.chat/python3-centos7.html
http://ask.xmodulo.com/install-python3-centos.html
https://realpython.com/blog/python/python-virtual-environments-a-primer/
https://stackoverflow.com/a/11512580
Following the above I first install the software collection and then enable it. During the enabling an error is flagged w.r.t. virtualenvwrapper which I have sourced somewhere in my environment:
============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Installing: rh-python35 x86_64 2.0-2.el7 centos-sclo-rh 2.7 k Installing for dependencies: rh-python35-python x86_64 3.5.1-6.el7 centos-sclo-rh 52 k rh-python35-python-devel x86_64 3.5.1-6.el7 centos-sclo-rh 193 k rh-python35-python-libs x86_64 3.5.1-6.el7 centos-sclo-rh 7.4 M rh-python35-python-pip noarch 7.1.0-2.el7 centos-sclo-rh 1.5 M rh-python35-python-setuptools noarch 18.0.1-2.el7 centos-sclo-rh 400 k rh-python35-python-virtualenv noarch 13.1.2-1.el7 centos-sclo-rh 1.7 M rh-python35-runtime x86_64 2.0-2.el7 centos-sclo-rh 1.1 M Transaction Summary ==============================================================================================================================
scl enable rh-python35 bash /opt/rh/rh-python35/root/usr/bin/python: Error while finding spec for 'virtualenvwrapper.hook_loader' (: No module named 'virtualenvwrapper') virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/opt/rh/rh-python35/root/usr/bin/python and that PATH is set properly.
Assuming that what I needed to do was to install a version of virtualenvwrapper within the enabled python3 environment I checked that I was running python3 (both by examining the SCL variable and looking at the current path to python and then attempted to pip install it.
which python /opt/rh/rh-python35/root/usr/bin/python echo $X_SCLS rh-python35
The current error that I face is a permission error on the /opt subdirectory in which the virtualenvwrapper and dependencies should be installed:
pip install virtualenvwrapper You are using pip version 7.1.0, however version 8.1.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting virtualenvwrapper Downloading virtualenvwrapper-4.7.2.tar.gz (90kB) 100% |████████████████████████████████| 94kB 2.2MB/s Requirement already satisfied (use --upgrade to upgrade): virtualenv in /opt/rh/rh-python35/root/usr/lib/python3.5/site-packages (from virtualenvwrapper) Collecting virtualenv-clone (from virtualenvwrapper) Downloading virtualenv-clone-0.2.6.tar.gz Collecting stevedore (from virtualenvwrapper) Downloading stevedore-1.17.1-py2.py3-none-any.whl Collecting pbr>=1.6 (from stevedore->virtualenvwrapper) Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB) 100% |████████████████████████████████| 98kB 143kB/s Collecting six>=1.9.0 (from stevedore->virtualenvwrapper) Downloading six-1.10.0-py2.py3-none-any.whl Installing collected packages: virtualenv-clone, pbr, six, stevedore, virtualenvwrapper Running setup.py install for virtualenv-clone Complete output from command /opt/rh/rh-python35/root/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-eehmolw7/virtualenv-clone/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ljhc7er5-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib copying clonevirtualenv.py -> build/lib running install_lib copying build/lib/clonevirtualenv.py -> /opt/rh/rh-python35/root/usr/lib/python3.5/site-packages error: could not create '/opt/rh/rh-python35/root/usr/lib/python3.5/site-packages/clonevirtualenv.py': Permission denied ---------------------------------------- Command "/opt/rh/rh-python35/root/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-eehmolw7/virtualenv-clone/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ljhc7er5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-eehmolw7/virtualenv-clone










