views:

64

answers:

1

Whilst writing working my way through a list of scripts I need to write I started using the MySQLdb package. This all worked fine in my Terminal by doing a simple python at the command line then import MySQLdb. However after about 30 minutes I figured I better move this to Eclipse incase I start making some stupid mistakes... Eclipse for some reason cannot see MySQLdb:

Unresolved import: MySQLdb  
MySQLdb Found at:

I then proceeded to scratch my head and go back to the terminal to see if it works... and low and behold:

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
>>> 

I am utterly confused as to what I have done. Could someone please point out my stupid mistake and any solutions? I have yet to master all this python installing/egg business. Cheers

+2  A: 

Could this be the answer; your current path does no longer exist: http://bugs.python.org/issue6612 thus os.getcwd () doesn't work.

gauteh