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

例如:import pkg_resources失败

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

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

 1 $python
 2 Python 2.5.4 (r254:67916, May 31 2010, 15:03:39)
 3 [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
 4 Type "help", "copyright", "credits" or "license" for more information.
 5 >>> import pkg_resources
 6 Traceback (most recent call last):
 7 File "<stdin>", line 1, in <module>
 8 ImportError: No module named pkg_resources
 9 >>>
10 
11 [admin@rs1c07296 /home/admin/wenwen]
12 $python
13 Python 2.5.4 (r254:67916, May 31 2010, 15:03:39)
14 [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
15 Type "help", "copyright", "credits" or "license" for more information.
16 >>> import sys;
17 >>> print sys.path
18 ['', '/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']
19 >>>

 

转载于:https://www.cnblogs.com/-sunshine/p/5281034.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值