我想重新安装virtualenv。我成功地做了:
pip uninstall virtualenv
然后重新安装我试过:
pip install virtualenv
导致错误:error: /lib/python2.7/site-packages/virtualenv.py: Permission denied
所以我试过了:
sudo pip install virtualenv
导致错误:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
Q1:为什么sudo会导致这样的问题?我已经读过这个错误是由于没有正确安装setuptools引起的。但为什么只能用sudo命令?这会导致python在其他地方寻找其资源吗?
有关我的设置的一些细节:
我在MacOS 10.9.4上。
我不确定为什么,但我似乎在两个地方设置了python:
Q2:为什么这两个位置?从我可以告诉pip和pip3在第二个位置安装东西。也许我有太多版本的python在运行?
下载来自交互式python控制台的sys.path打印:
['',
'/lib/python2.7/site-packages/setuptools-5.4.1-py2.7.egg',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.2.2-py2.7.egg',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.7.2-py2.7.egg',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/docutils-0.11-py2.7.egg',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Pygments-1.6-py2.7.egg',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MarkupSafe-0.23-py2.7-macosx-10.9-x86_64.egg',
'/usr/local/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/Sphinx-1.2.2-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/Jinja2-2.7.2-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/docutils-0.11-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/Pygments-1.6-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/MarkupSafe-0.23-py2.7-macosx-10.9-x86_64.egg',
'/lib/python2.7/site-packages',
'/lib/python2.3/site-packages',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Users/david/Library/Python/2.7/lib/python/site-packages',
'/Library/Python/2.7/site-packages',
'/usr/local/lib/python2.7/site-packages',
'/lib/python2.3/site-packages']
答案 0 :(得分:1)
虽然我不确定我是否完全了解原始问题的来源(不知道Q1的答案),但我通过卸载/取消链接Python与Homebrew来修复它,然后重新设置所有内容关注THIS教程。我得到的主要教训是:
/lib
中有python安装的原因。我还在Homebrew中安装了python,它在/usr/local/lib/
中创建了第二个安装。经过一段时间不小心我正在使用/安装包以跟上我。