3

I wanted to try sqlalchemy for my code but in order to use it I need first to install mysql-python. I downloaded the package but when I tried {python setup.py install} it gives me an error that I cannot understand.

running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-i686-2.7/MySQLdb
running build_ext
building '_mysql' extension
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-i686-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 'i686-linux-gnu-gcc' failed with exit status 1

after sudo apt-get install python2.7-dev

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
python2.7-dev : Depends: libpython2.7-dev (= 2.7.4-2ubuntu3.2) but it is not     going to be installed
             Depends: libexpat1-dev but it is not installable
E: Unable to correct problems, you have held broken packages.
tlbakh
  • 71
  • 2
  • 6

3 Answers3

9

If it is for python 3.6, you have to install corresponding python3-dev, i.e:

sudo apt-get install python3.6-dev
Pranav Nandan
  • 361
  • 3
  • 10
3

You probably haven't installed python-dev, so I would suggest you to run

sudo apt-get install python-dev

Source: Python.h missing from Ubuntu 12.04

Community
  • 1
  • 1
  • Actually, I already tried. This is the error it gave. `Reading package lists... Done Building dependency tree Reading state information... Done Package python-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: python E: Package 'python-dev' has no installation candidate` – tlbakh Jan 12 '14 at 10:43
  • Hmm, that's a bit strange... Can you try looking up `python-dev` in Synaptic and install it from there? – David de Kleer Jan 12 '14 at 10:48
  • If I didn't do something wrong, synaptic says python2.7-dev is broken. That's weird. – tlbakh Jan 12 '14 at 10:57
  • Agreed, I don't really know what's the cause of that :-( Unmet dependencies or something? What if you try `sudo apt-get install python2.7-dev`? – David de Kleer Jan 12 '14 at 11:00
  • Wow! The error I got doesn't look good. What should I do? Added it to question. – tlbakh Jan 12 '14 at 11:04
  • Maybe you could try my answer [here](http://stackoverflow.com/questions/19136410/how-to-install-libmysqld-dev-on-ubuntu-12-04/19136948#19136948)? The problem seems to be that you have some broken packages. Otherwise I can't really think of something else. – David de Kleer Jan 12 '14 at 11:12
  • I tried and it said `0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ` – tlbakh Jan 12 '14 at 11:57
  • And how about trying to install the dependencies `libpython2.7-dev` and `libexpat1-dev` with Synaptic (and if that works, `python2.7-dev` after that?) You have to fix those dependencies, otherwise you can't install `python2.7-dev`. – David de Kleer Jan 12 '14 at 12:21
  • libpython2.7-dev seems broken too and could not be downloaded. I think I will be gone insane. – tlbakh Jan 12 '14 at 12:50
  • Hmm, somehow there must be a way to fix those dependencies, maybe try to ask it at a Linux-related forum? – David de Kleer Jan 12 '14 at 14:10
  • Make sure that if you're using a python version that isn't a default (like the newly released 3.7) you install `pythonVERSION-dev` – Tadaboody Jul 09 '18 at 10:01
-1

try this out:

sudo apt-get install zlib1g-dev
Sachin Singh
  • 7,107
  • 6
  • 40
  • 80