8

I'm trying to install PyQt5 on my Ubuntu 12.04 box. So after downloading it from here I untarred it, ran python configure.py and make. Make however, results in the following:

cd qpy/ && ( test -f Makefile || /opt/qt5/bin/qmake /home/kram/Downloads/PyQt-gpl-5.0/qpy/qpy.pro -o Makefile ) && make -f Makefile 
make[1]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy' is entered
cd QtCore/ && ( test -f Makefile || /opt/qt5/bin/qmake /home/kram/Downloads/PyQt-gpl-5.0/qpy/QtCore/QtCore.pro -o Makefile ) && make -f Makefile 
make[2]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy/QtCore' is entered
g++ -c -pipe -fno-strict-aliasing -O2 -Wall -W -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -I/opt/qt5/mkspecs/linux-g++ -I. -I. -I../../QtCore -I/usr/local/include/python2.7 -I/opt/qt5/include -I/opt/qt5/include/QtCore -I. -o qpycore_chimera.o qpycore_chimera.cpp
qpycore_chimera.cpp:21:20: fatal error: Python.h: File or folder does not exist
compilation terminated.
make[2]: *** [qpycore_chimera.o] Error 1
make[2]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy/QtCore' is left
make[1]: *** [sub-QtCore-make_first] Error 2
make[1]: Map '/home/kram/Downloads/PyQt-gpl-5.0/qpy' is left
make: *** [sub-qpy-make_first-ordered] Error 2

(I translated some parts of the error message from Dutch to English, so some words may be a bit off from the normal wording..)

Does anybody what the problem is here? Where could the relevant Python.h file be?

Community
  • 1
  • 1
kramer65
  • 50,427
  • 120
  • 308
  • 488

4 Answers4

29

The problem is that the include path for all python headers in every Makefile will be pointing to /usr/local/include/python2.7 , which should have been /usr/include/python2.7

There are 2 possible solutions for this. Either you can change all the occurrence of this in every Makefile or else you can create a symlink to that location

sudo ln -s /usr/include/python2.7 /usr/local/include/python2.7

Now you can run make

Rony Varghese
  • 578
  • 8
  • 18
6
sudo apt-get install python-dev

Your missing the python header files.

Jakob Bowyer
  • 33,878
  • 8
  • 76
  • 91
  • I thought that as well, but I've already got them installed. After running your command it says python-dev is already the newest version. – kramer65 Jul 17 '13 at 11:45
  • What version are you installing for and what version of python-dev do you have – Jakob Bowyer Jul 17 '13 at 11:47
  • I don't exactly know how to check the version of python-dev, but I ran `sudo apt-get install python2.7-dev`, which also told me I've got the latest version. – kramer65 Jul 17 '13 at 12:07
  • Is Python.h in your include directory? is the library registered (ldconfig)? Is it the correct version? Did you try manually setting the path for python? – Sebastian Lange Jul 17 '13 at 12:10
  • @SebastianLange - Wow, that's a lot of questions which I don't know the answer to. Which include directory are you talking about? Where can I find that include dir? How can I check whether the library is registered? Which version are you talking about? The version of PyQt (that's 5), or the version of Python (that's 2/7)? I didn't try manually setting the path for python. How would you sgguest I could do that? – kramer65 Jul 17 '13 at 13:38
  • You probably should read more about developing in c++ under linux. To be fair some info: The include directory is the path the compiler will search for header files. Standard include directory would be ``/usr/include``. Libraries should be located in ``/usr/lib`` with essential libs in ``/lib``. The configure script would have the possibility to specify parameters which probably can be used to specify extra directories and files. – Sebastian Lange Jul 18 '13 at 05:20
  • @SebastianLange - Thanks for all those tips. I checked out /usr/include, and there is no Python.h present. Would you know where to get it so that I could place it there? Or should I install something to get it in there? – kramer65 Jul 19 '13 at 11:41
  • 1
    Try running ``locate Python.h``. If no results are given run ``find / -type f -name "Python.h" 2>/dev/null``. This is where your file is located. Add this path to your inclusion directories calling ``python configure.py`` with correct parameter. Check configure help for known parameters. – Sebastian Lange Jul 22 '13 at 08:30
1

The problem you're having is that PyQt assumes you're not using your distro's managed python, and instead defaults to looking for sip in /usr/local/include/python2.7.

Luckily, configure.py provides options to override the python and sip include locations:

python configure.py --sip-incdir /usr/include/python2.7 py_inc_dir=/usr/include/python2.7

This solution should preferred to symlinking /usr/include/python2.7 into /usr/local/include/python2.7 as that will enable manually installed software to pollute (or corrupt packages installed to) distro-managed paths.

fmoo
  • 769
  • 5
  • 11
0

It is better to add existing header files to the project directory in both QTCreator and Anjuta IDE.

F.Tamy
  • 594
  • 6
  • 17