I want to use virtualenv with Python 3 on Ubuntu 18.04. Specifically, I'm using Python 3.6.6 and virtualenv 16.0.0.
I installed virtualenv with
sudoas suggested in the answers here:sudo pip3 install --upgrade virtualenvI created a new virtualenv using
python3 -m virtualenv venv. And activated it as usual:source venv/bin/activate.When I try to install my Python project with
python setup.py installI get the following error message:
running install running bdist_egg running egg_info error: [Errno 13] Permission deniedIf I use sudo to create the virtualenv in step 2, then I get a different error message in step 3:
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory: [Errno 13] Permission denied: '/home/stefan/git-repos/tng-sdk-project/venv/lib/python3.6/site-packages/test-easy-install-3769.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was: /home/stefan/git-repos/tng-sdk-project/venv/lib/python3.6/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
Please make the appropriate changes for your system and try again.I've been googling and trying stuff for hours now and I can't get it to work properly. It seems like whatever I try leads to more, new errors... Any ideas?
Well, sudo python setup.py install works inside the virtualenv, but this can't be the solution.
1 Answer
Most probably used sudo for some instructions that create some folder with root ownership.
Deactivate the virtual env.
Try fix owner recursively:
sudo chown -R stefan:stefan /home/stefan/git-repos/tng-sdk-project/Activate virtual env and test it.