Segmentation fault MySQLdb

杀马特。学长 韩版系。学妹 提交于 2021-01-28 02:06:46

问题


I have installed MySQLdb for python, and have the following code.

   import MySQLdb

    conn = MySQLdb.connect(host="hello")

Everytime I run this on terminal, I get Segmentation fault (core dumped)

But when I put the above lines in hi.py file, and run python hi.py, then I do not see this error in terminal.

Could anyone give me an advice to fix this problem?

$ python  
>>> import MySQLdb   
>>> conn = MySQLdb.connect(host="hello")      
Segmentation fault (core dumped)

This is the command I typed in the terminal. And got segmentation fault error.


回答1:


I have encountered a similar problem before, try checking if you are using python2 with the terminal.

MySQLdb does not work with python3. If you want to work with python3 use mysql-connector-python

You can install it with pip: pip install mysql-connector-python



来源:https://stackoverflow.com/questions/33112469/segmentation-fault-mysqldb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!