0
~$ PYTHONPATH=/usr/local/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg pypy
Python 2.7.13 (6.0.0+dfsg-1~ppa1~ubuntu14.04, Apr 28 2018, 03:15:01)
[PyPy 6.0.0 with GCC 4.8.4] 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.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
  File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py", line 7, in <module>
    __bootstrap__()
  File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: unable to load extension module '/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.so': /usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.so: undefined symbol: _Py_ZeroStruct

And my MySQL-python version is 1.2.5.

This link https://pypi.org/project/MySQL-python/ says PyPy is supported.

Anyone can help me how to use MySQL-python with pypy?

Da Lin
  • 179
  • 2
  • 9

1 Answers1

0

PyPy manages a different sys.path than CPython, you cannot mix the two. Do not set PYTHONPATH to the CPython dist-packages, reinstall anything you wish to use with pypy -mpip install.

mattip
  • 2,360
  • 1
  • 13
  • 13