16

I have tried this and this and this and this

None of those install python-dev, I got my amd64 system, 14.04 up and running, as I try to install wagtail, a django cms, I get the error:

     pysass.c:4:20: fatal error: Python.h: No such file or directory

     #include <Python.h>

                        ^

    compilation terminated.

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

    ----------------------------------------
    Cleaning up...
    Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/
    libsass/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace
    ('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ojWg1O-record/install-
    record.txt --single-version-externally-managed --compile failed with error code 1 in 
    /tmp/pip_build_root/libsass
    Storing debug log for failure in /home/payload/.pip/pip.log

How can I fix this and install the package?

It's because of the missing Python.hc header which is included in the python-dev package.

When I tried the above links, it says:

apt-get install python-dev

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

for apt-get install python2.7-dev

Package python2.7-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

E: Package 'python2.7-dev' has no installation candidate

I have researched on the debian archives and found a package for python 2.7.8-1 but that couldn't be installed.

Tried this on launchpad too but doesn't work.

2 Answers 2

24

Are you sure you are doing it right?

This is my output for # apt-get install python2.7-dev

root@olympus:/home/zeus# apt-get install python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libexpat1-dev libpython2.7-dev
The following NEW packages will be installed:
  libexpat1-dev libpython2.7-dev python2.7-dev
0 upgraded, 3 newly installed, 0 to remove and 7 not upgraded.
Need to get 22.4 MB of archives.
After this operation, 35.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Try doing this as root (su)

Also, try running # apt update and make sure Multiverse and universe are enabled (See How do I enable the "Universe" repository?). I also got backports enabled in my system, not sure whether that makes a difference in this case.

5
  • imgur.com/dI6n3Pq this is my screenshot. how to enable multiverse and universe?
    – x0x
    Sep 14, 2014 at 20:23
  • 4
    @John: Type the following command: sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" Sep 14, 2014 at 20:55
  • 2
    +1.. I was getting similar error when trying to install using python3.5. After Installing python3.5-dev the error was gone Jun 1, 2016 at 13:47
  • I had the same #include <Python.h> error and running sudo apt-get install python-dev fixed it. This is with python2.7. Jul 8, 2016 at 14:52
  • I tried as told and it works. Feb 27 at 8:39
2

try this:

sudo apt-get install python3

instead of python-dev where package "python3" contains python3 and python-dev

1
  • 1
    I just ran into this with the pyhon-image from docker-hub. They have upgraded to Debian Bookworm, in which things have apparently moved around. They left a hint in my error-message saying python-dev-is-python3.
    – Chris
    Jul 19, 2023 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .