Issue
I was following this tutorial rel="noreferrer">http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world/page/5
When I got to virtualenv flask
command, I received this error message:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
This makes sense as the point of virtualenv is to create a new environment which you can control, and the --user
command places everything in a specific location, defeating the objective of separation of dev environment.
It seems like pip defaults to --user
installations though, can I change this default behavior? And, even better, can I get pip to play nice with virtualenv at all times?
To clarify, here is what my terminal looks like.
MELCHIOR:miguelgrinberg-microblog megablanc$ virtualenv flask
New python executable in flask/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/megablanc/Dev...log/flask/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/megablanc/Library/Python/2.7/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/megablanc/Dev...log/flask/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
Solution
You don't need to set the --user
flag. After you create your virtualenv (virtualenv flask
), activate it: source flask/bin/activate
. Your shell should look something like (flask) ~>
.
Once your virtualenv is activated, you should be able to pip install packages without issue. For example, pip install numpy
. They'll be installed in: lib/python2.6/site-packages/
(for whatever version of Python you are using)
Answered By - benlaird Answer Checked By - Timothy Miller (WPSolving Admin)