您的位置:首页 > 编程语言 > Python开发

python中import失败解决的简单办法

2016-03-15 20:33 519 查看
例如:import pkg_resources失败

可以print sys.path查看,从其他机器上cp -r过来即可,如下例子:

从另外一个正常的机器上scp过来/usr/ali/lib/python2.5/site-packages目录。

$python
Python 2.5.4 (r254:67916, May 31 2010, 15:03:39)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pkg_resources
>>>

[admin@rs1c07296 /home/admin/wenwen]
$python
Python 2.5.4 (r254:67916, May 31 2010, 15:03:39)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys;
>>> print sys.path
['', '/usr/ali/lib/python25.zip', '/usr/ali/lib/python2.5', '/usr/ali/lib/python2.5/plat-linux2', '/usr/ali/lib/python2.5/lib-tk', '/usr/ali/lib/python2.5/lib-dynload', '/usr/ali/lib/python2.5/site-packages']
>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: