Steps for installing python-mysqldb in ubuntu

Source: Internet
Author: User

/Usr/bin/python

Under python2.6

An error occurred while executing sudo python setup. py build and sudo python setup. py install (the mysql_config file is missing under/usr/bin ).
To solve this problem, install the following three packages:

The code is as follows: Copy code

Sudo apt-get install mysql-client
Sudo apt-get install libmysqlclient-dev
Sudo apt-get install python-dev

Then you will find/usr/bin/mysql_config
This file is now available.

However, python2.7 fails.
The error message "setuptools" is missing.

The code is as follows: Copy code

Sudo apt-get install python-setuptools

Installed. Version 2.7 is not recognizable.

The code is as follows: Copy code

Extracting in/tmp/tmp9SVXrX
 
Traceback (most recent call last ):
File "setup. py", line 7, in <module>
Use_setuptools ()
File "/backup/software/MySQL-python-1.2.4b4/distribute_setup.py", line 145, in use_setuptools
Return _ do_download (version, download_base, to_dir, download_delay)
File "/backup/software/MySQL-python-1.2.4b4/distribute_setup.py", line 125, in _ do_download
_ Build_egg (egg, tarball, to_dir)
File "/backup/software/MySQL-python-1.2.4b4/distribute_setup.py", line 98, in _ build_egg
Tar = tarfile. open (tarball)
File "/usr/local/lib/python2.7/tarfile. py", line 1665, in open
Raise ReadError ("file cocould not be opened successfully ")
Tarfile. ReadError: file cocould not be opened successfully

This version has no problems in mac systems.

Upgrade the system.

The code is as follows: Copy code
Apt-get upgrade

I insist on using python2.7. On the one hand, because he is new, on the other hand, there is a regular function.

The code is as follows: Copy code

Sub
 
Import re
 
Block = re. sub (reg, rep, content, 1000, re. I | re. S)

In python2.6, only four parameters can be input. I used five parameters here.

It seems that the new version of python2.7 adds a parameter.

Guess:

The two paths contain python version execution files.

The code is as follows: Copy code
Usr/bin
Usr/local/bin

Apt-get install python2.7-mysqldb, not allowed

Discussion in CSDN Forum

Check the error carefully. Don't imagine it yourself. Is it related to your zip? It should be to detect the lack of setuptools. First download distribute and install mysql-python...

I have re-compiled python (with zlib module), installed setuptools, modified the mysql-python configuration file, and finally completed the installation of mydsql-python.

The code is as follows: Copy code

./Configure -- prefix =/usr/local/python27
 
-- With-zlib =

Find information that python2.7 does not support-with-zlib

My days

Upgrade all to 3.3

As a result, python 3.3 first tells you that print ('A') is required when the print syntax is changed ')

The installation of python-mysql fails. The query information says that it currently supports up to 2.7 days.

Finally, I compromised.

Change local to 2.6

In this way, it is synchronized with the server.

In this way, both re. sub and database can be used.

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.