問題:
I'm deploying a Django app to a dev server and am hitting this error when I run pip install -r requirements.txt
:我正在將 Django 應用程序部署到開發服務器,並在運行pip install -r 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
pkg_resources
appears to be distributed with setuptools
. pkg_resources
似乎與setuptools
一起setuptools
。 Initially I thought this might not be installed to the Python in the virtualenv, so I installed setuptools 2.6
(same version as Python) to the Python site-packages in the virtualenv with the following command:最初我認爲這可能沒有安裝到 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
EDIT: This only happens inside the virtualenv.編輯:這隻發生在 virtualenv 內部。 If I open a console outside the virtualenv then pkg_resources
is present, but I am still getting the same error.如果我在 virtualenv 之外打開控制檯,則存在pkg_resources
,但我仍然遇到相同的錯誤。
Any ideas as to why pkg_resources
is not on the path?關於爲什麼pkg_resources
不在路徑上的任何想法?
解決方案:
參考一: https://stackoom.com/question/VF5n參考二: No module named pkg_resources