0

I am new at Python and SQLAlchemy and I was trying to play with them a little bit, but whenever I run a test it gives me the following error :

Traceback (most recent call last):
  File "/home/zakaria/workspace-python/Jerreb/essai/tejriba.py", line 11, in <module>
    engine = create_engine("mysql://root:root@localhost/python")
  File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.7-py2.7-linux-i686.egg/sqlalchemy/engine/__init__.py", line 346, in create_engine
    return strategy.create(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.7-py2.7-linux-i686.egg/sqlalchemy/engine/strategies.py", line 74, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.7-py2.7-linux-i686.egg/sqlalchemy/connectors/mysqldb.py", line 64, in dbapi
    return __import__('MySQLdb')
  File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-i686.egg/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: /usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-i686.egg/_mysql.so: undefined symbol: _Py_ZeroStruct

I am working with PyDev.

This is the project architecture:

Project Architecture

And these are the libs I have imported :

Project Libs

What is the problem and how can I fix it?

Thanks!

1 Answer 1

1

When I got this message, it turned out that, unbeknownst to me, the code was being run in the Python 3 interpreter, instead of Python 2. (This happened because I had installed Ubuntu's libapache2-mod-wsgi-py3 for a different project.) MySQL-python does not yet support Python 3. :'(

I don't know whether WSGI is involved for you, but try making sure you're not running Python 3.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.