Python没有Longers看到MySQLdb

时间:2010-07-08 12:47:09

标签: python import mysql

在编写我需要编写的脚本列表时,我开始使用MySQLdb包。通过在命令行python处执行简单的import MySQLdb,这在我的终端中运行良好。但是大约30分钟后我觉得我最好把它移到Eclipse上,因为我开始犯了一些愚蠢的错误......由于某种原因Eclipse无法看到MySQLdb:

Unresolved import: MySQLdb  
MySQLdb Found at:

然后我抓住了头,然后回到到终端,看看它是否有效......而且很低,看哪:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/MySQLdb/__init__.py", line 19, in <module>

  File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 7, in <module>
  File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 3, in __bootstrap__
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2553, in <module>
    working_set = WorkingSet()
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 384, in __init__
    self.add_entry(entry)
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 399, in add_entry
for dist in find_distributions(entry, True):
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1647, in find_on_path
    path_item = _normalize_cached(path_item)
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1794, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1788, in normalize_path
return os.path.normcase(os.path.realpath(filename))
  File "/usr/lib/python2.6/posixpath.py", line 364, in realpath
return abspath(filename)
  File "/usr/lib/python2.6/posixpath.py", line 337, in abspath
    path = join(os.getcwd(), path)
OSError: [Errno 2] No such file or directory
>>> 

我对自己的所作所为完全感到困惑。有人可以指出我的愚蠢错误和任何解决方案吗?我还没有掌握所有这个python安装/ egg业务。干杯

1 个答案:

答案 0 :(得分:2)

这可能是答案吗?您的当前路径不再存在:http://bugs.python.org/issue6612因此os.getcwd()不起作用。