Reputation: 195
I am trying to set up a virtualenv for the first time and I can't figure out what the issue is. Here is the output in terminal...
Traceback (most recent call last):
File "/bin/virtualenv", line 3, in <module>
virtualenv.main()
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 960, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1133, in install_python
mkdir(lib_dir)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 441, in mkdir
os.makedirs(path)
File "/usr/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: 'test_env'
I don't know why I would get a Permission denied error with just creating a virtualenv.
Upvotes: 0
Views: 810
Reputation: 7463
A virtualenv, on disk, is a directory with its own Python installation. The virtualenv
utility needs to create this directory, and by default it puts it into your current directory (as opposed to some standardized location like ~/.venvs
), which means that you need to be in the same directory as where you created the virtual environment every time you use it. The the Permission denied
message comes from it not being able to create the directory in the first place.
Most likely you don’t have write permission to whatever directory you’re in. Your current directory (which you can find with pwd
) should (usually) be somewhere in your home directory when trying to create a virtualenv.
Another possibility is that the directory already exists, but some of the necessary directory structure inside the virtualenv directory does not, and you don’t have write permission there. Usually, you want to use a name that does not correspond to an existing directory, and let the virtualenv
tool create it for you.
Upvotes: 1