pypy导入MySQL-Python库失败

时间:2018-12-21 11:20:13

标签: mysql-python pypy

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

我的MySQL-python版本是1.2.5。

此链接https://pypi.org/project/MySQL-python/表示支持PyPy。

任何人都可以帮助我如何在pypy中使用MySQL-python吗?

1 个答案:

答案 0 :(得分:0)

PyPy与CPython管理的sys.path不同,您不能将两者混在一起。不要将PYTHONPATH设置为CPython dist-package,请重新安装您希望与pypy -mpip install一起使用的任何内容。