3

I'm not sure if this should be here or in a python board however since this isn't happening anywhere else except on an Ubuntu 16.04 system I thought it might be the right place.

I have a Ubuntu 16.04 server set up with Amazon Ec2.

I have installed python3.6 using the first option in the best answer here:
How do I install Python 3.6 using apt-get?


I also installed pip3 using this method:

apt-get install python3-pip

Using pip3 I installed virtualenv and virtualenvwrapper

pip3 install virtualenv
pip3 install virtualenvwrapper

I set my virtualenv directory to the home directory by adding this to my .bashrc file

export WORKON_HOME=$HOME/.virtualenv

Then reloading bash using source ~/.bashrc

This all works fine.

The next step when I try and run

source /usr/local/bin/virtualenvwrapper.sh

Which is suggested by the packages website and several askubuntu articles example I get this error:

-su: /usr/local/bin/python3: No such file or directory
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=/usr/local/bin/python3 and that PATH is
set properly.

Firstly what does this mean and how is it resolved?

The next issue seems related.

It does seem I now have access to virtualenvwrapper commands.

When I run

mkvirtualenv test

The env is created in the expected location however I get the following output with and error:

Using base prefix '/usr'
New python executable in /home/web/.virtualenvs/test/bin/python3
Not overwriting existing python script /home/web/.virtualenvs/test/bin/python (you must use /home/web/.virtualenvs/test/bin/python3)
Installing setuptools, pip, wheel...done.
virtualenvwrapper_run_hook:12: permission denied:

1 Answers1

7

I think you just need to set the VIRTUALENVWRAPPER_PYTHON variable to be python3 before you run the virtualenvwrapper command.

So just add:

VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper.sh

to your .bashrc.

(From http://railslide.io/virtualenvwrapper-python3.html)

  • 1
    Wow! Welcome to Ask Ubuntu! *Great* first answer! (We don't see many of those around here) ;-) – Fabby Apr 16 '18 at 22:28