Import error depending on where importing from

Chris Liechti cliechti at
Sun Sep 1 13:19:22 CEST 2002

"Jay O'Connor" <joconnor at> wrote in 
news:20020831.231529.1350573793.13153 at
> For certain reasons, I had to put the MySQLdb files in my own directory
> (called 'lib').   Now, when I'm in the lib directory I can import MySQLdb
> and use it fine.  However, when I'm one directory up, and I try to do
> "from lib import MySQLdb" I get 
> ImportError: _mysql: init failed

you need to make sure that the module is in a directory that is in 
"sys.path". you can add you "lib" with 
"sys.path.append(os.path.abspath('lib'))" or whatever is appropriate for 

Chris <cliechti at>

More information about the Python-list mailing list