我正在将一个Django应用程序部署到开发服务器,并在运行pip install requirements.txt时遇到此错误:
Traceback (most recent call last):
File "/var/www/mydir/virtualenvs/dev/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
Run Code Online (Sandbox Code Playgroud)
pkg_resources似乎随setuptools一起分发.最初我认为这可能没有安装到virtualenv中的python所以我使用以下命令将setuptools(2.6,与Python相同的版本)安装到virtualenv中的Python站点包中
sh setuptools-0.6c11-py2.6.egg --install-dir /var/www/mydir/virtualenvs/dev/lib/python2.6/site-packages
Run Code Online (Sandbox Code Playgroud)
编辑这只发生在virtualenv中.如果我在virtualenv之外打开一个控制台,那么就存在pkg_resources
但我仍然得到同样的错误.关于为什么pkg_resources不在路径上的任何想法?
我刚刚在Mac上将Python更新为2.6.4.我从dmg包安装.
二进制文件似乎没有正确设置我的Python路径,所以我添加'/usr/local/lib/python2.6/site-packages'了.bash_profile
>>> pprint.pprint(sys.path)
['',
'/Users/Bryan/work/django-trunk',
'/usr/local/lib/python2.6/site-packages',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages']
Run Code Online (Sandbox Code Playgroud)
显然,这不是所有必需的路径,因为我无法运行iPython.
$ ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named `pkg_resources`
Run Code Online (Sandbox Code Playgroud)
我已完成谷歌搜索,我无法弄清楚如何安装pkg_resources或确保它在路上.
我需要做些什么来解决这个问题?