Python MySQLdb installation error: pymemcompat. h: 10: 20: Fatal error Solution

Source: Internet
Author: User

Note: This document uses the redhat series as an example. If you are using the debian series, replace yum install with sudo apt-get install.

1) first download mysql-python-1.2.3.tar.gz from the official website.

2) in this case, you can directly decompress the package or use the tar command in the shell to decompress the package. j will go to its unzipping directory and execute python setup. py install. This may cause a series of problems:
A) The system prompts that setuptools is missing because the components provided by setuptools are required for mysql-python installation,

Download the setuptools corresponding to python installed on your system,

I downloaded the setuptools-0.6c11-py2.7.egg (md5) Here, to the download directory, execute sh setuptools-0.6c11-py2.7.egg,

Then install it!

B) continue to execute python setup. py install. the following error may occur:
======> Pymemcompat. h: 10: 20: Fatal error: Python. h: No file or directory compilation interruption.
The cause of this problem is that python in the system is self-built, but the python Development Kit is not installed, So execute the following command in shell:
Click (here) to fold or open

Yum install python-devel
C) similar errors may occur after executing commands like B:
========>_Mysql. c: 36: 23: Fatal error: my_config.h: No file or directory compilation interruption.
Obviously, the solution is the same as above, because the mysql Development Kit is not installed, and you can solve the problem by executing the following command!
Click (here) to fold or open

Yum install mysql-devel
3) Finally, the problem is solved successfully! (PS: If you have already installed mysql, an error will be triggered if you do not have it. You only need to install it)
4) The test is as follows:
Click (here) to fold or open

>>> Db = MySQLdb. connect (user = 'root', db = 'test', passwd = '000000', host = '000000. 0.0.1 ') // database connection
>>> Cursor = db. cursor () // create a cursor
>>> Cursor.exe cute ('select name from test order by id') // execute the query statement.
>>> Names = [row [0] for row in cursor. fetchall ()] // parse the list to extract data
>>> Print names
['Loogn', 'qiang ']
>>> Db. close () // close the database
>>>

 


Attachment: Support for installing python mysqldb in ubuntu:

Sudo apt-get install mysql-server mysql-client libmysqlclient15-dev

Http://peak.telecommunity.com/dist/ez_setup.py wget-c
Sudo python ez_setup.py

Sudo easy_install MySQL-python

Author: xrzs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.