我有一个无法正确执行导入的python文件。
如果我转到python提示符,我可以手动导入模块而不会出错。
Python 2.4.3 (#1, Feb 22 2012, 16:06:13)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from amqplib import client_0_8 as amqp
当我使用pdb逐步执行程序时,执行导入的结果:
-> from amqplib import client_0_8 as amqp
(Pdb) s
--Call--
> /home/ralphie/Desktop/Projects/catamaran/build/bdist.linux-i686/egg/amqplib/__init__.py(0)?()
当我检查sys.path:
时Python 2.4.3 (#1, Feb 22 2012, 16:06:13)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from amqplib import client_0_8 as amqp
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg',
'/usr/lib /python2.4/site-packages/mechanize-0.2.5-py2.4.egg',
'/usr/lib/python2.4/site-packages/ClientForm-0.2.10-py2.4.egg',
'/usr/lib/python2.4/site-packages/simplejson-2.3.2-py2.4-linux-i686.egg',
'/usr/lib/python2.4/site-packages/amqplib-1.0.0-py2.4.egg',
'/usr/lib/python24.zip',
'/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2',
'/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages/Numeric',
'/usr/lib/python2.4/site-packages/PIL',
'/usr/lib/python2.4/site-packages/gtk-2.0']
它不是来自环境变量,我删除了所有.pyo& .pyc文件。
我根本不知道疯狂的鸡蛋参考来自哪里。
任何线索都真诚地感激。
答案 0 :(得分:0)
尝试将python升级到更新的版本,我在python2.4和amqp上遇到了很多问题。
即使import语句成功,在调用之前不会测试或执行功能逻辑。