我正在学习本教程
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world/page/5
当我得到virtualenv flask命令时,我收到此错误消息:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
这是有道理的,因为virtualenv的目的是创建一个你可以控制的新环境,而–user命令将所有东西都放在一个特定的位置,从而破坏了开发环境分离的目标.
看来pip默认为–user安装,我可以更改此默认行为吗?而且,更好的是,我可以随时获得与virtualenv一起玩的好处吗?
为了澄清,这是我的终端的样子.
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,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
解决方法
您不需要设置–user标志.创建virtualenv(virtualenv flask)后,激活它:source flask / bin / activate.你的shell应该看起来像(烧瓶)〜>.
一旦你的virtualenv被激活,你应该能够毫无问题地推送安装包.例如,pip install numpy.它们将被安装在:lib / python2.6 / site-packages /(对于你正在使用的任何Python版本)