Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't pip install mysql-python

Tags:

python

pip

django

I'm trying to get django/pip/mysql working and i can't seem to figure out how to install mysql-python. this is the error i receive when trying to install mysql-python

pip install mysql-python

Downloading/unpacking mysql-python
  Downloading MySQL-python-1.2.4.zip (113kB): 113kB downloaded
  Running setup.py egg_info for package mysql-python
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
    Extracting in /tmp/tmp5jjdpf
    Now working in /tmp/tmp5jjdpf/distribute-0.6.28
    Building a Distribute egg in /home/brian/flaskapp/build/mysql-python
    /home/brian/flaskapp/build/mysql-python/distribute-0.6.28-py2.7.egg

Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
    _mysql.c:29:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /home/brian/flaskapp/bin/python -c "import setuptools;__file__='/home/brian/flaskapp/build/mysql-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ur7r16-record/install-record.txt --single-version-externally-managed --install-headers /home/brian/flaskapp/include/site/python2.7:
    running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb

creating build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

running build_ext

building '_mysql' extension

creating build/temp.linux-x86_64-2.7

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG

_mysql.c:29:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/brian/flaskapp/bin/python -c "import setuptools;__file__='/home/brian/flaskapp/build/mysql-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ur7r16-record/install-record.txt --single-version-externally-managed --install-headers /home/brian/flaskapp/include/site/python2.7 failed with error code 1 in /home/brian/flaskapp/build/mysql-python
Storing complete log in /home/brian/.pip/pip.log

Googling reveals i need to install python-dev but whenever i try to install with

sudo apt-get install python-dev

i get this error:

E: Package 'python-dev' has no installation candidate

I'm currently using linux mint 15 RC and i think that might be the issue...but i'm not sure. I'm out of ideas:(

like image 684
brianwu02 Avatar asked Sep 02 '13 01:09

brianwu02


People also ask

Can you pip install MySQL?

Installation: To install Python-mysql-connector module, one must have Python and PIP, preinstalled on their system.

Does Python 3.8 support MySQL?

It is sadly known that MYSQL has low compatibility with python.

Can not install with PIP?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.


2 Answers

try downloading python-dev through software manager:

sudo apt-get install python-dev
like image 55
montiniz Avatar answered Oct 12 '22 06:10

montiniz


ubuntu: sudo apt-get install libmysqlclient-dev

like image 33
e.thompsy Avatar answered Oct 12 '22 05:10

e.thompsy