我有两个Ubuntu服务器。在服务器服务器A 下面输入正常工作:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> from requests.packages.urllib3.poolmanager import PoolManager
然而服务器B ,
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> from requests.packages.urllib3.poolmanager import PoolManager
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named packages.urllib3.poolmanager
两者都有相同的版本:
Name: requests
Version: 2.7.0
Location: /usr/local/lib/python2.7/dist-packages
Requires:
这是怎么回事?
这是服务器B的路径:
/usr/local/lib/python2.7/dist-packages/greenlet-0.4.5-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/dist-packages/gevent-1.0.1-py2.7-linux-x86_64.egg
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
事情是Sever B的文件位于此处,所以它应该找到它:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3
答案 0 :(得分:4)
这是python-requests
中的一个问题,因为所有者并没有像提到here那样在Pypi和Ubuntu存储库之间打包它。
<强>解决方案:强>
直接使用urllib3
:
from urllib3.poolmanager import PoolManager
完全删除python-requests
的所有副本,然后使用pip
或apt-get
重新安装,packages.urllib3
内部包含{{1}}。