I find that many people have troubles installing python packages with pip because python-dev is not installed. Mainly, the error:
fatal error: Python.h: No such file or directory
So the question: Should python-dev be a required dependency of pip? Or is this only an issue for certain packages being installed with pip, and if so, are there certain steps to take to ensure users do not encounter the error when installing your modules?
I don't think this actually belongs on StackOverflow, but in case I'm wrong…
First, python-dev
is not a Python thing, it's an Ubuntu or Fedora or some other distro thing. If you download, build, and install Python, or run any binary installer from python.org, you get Python.h
installed in an appropriate place. Many linux distros like to split packages into subpackages, moving stuff you only need for building into a -dev
or similar package, and there's absolutely nothing wrong with doing that to Python, but it's still something the distro is doing.
Second, Python.h
is not needed for building all packages, only those that include C extension modules. Since many packages are pure-Python and have no such extension modules, it makes sense that a distro's pip
package wouldn't require its python-dev
package. (In the same way that a distro's pip
package probably wouldn't require a C compiler.)
Third, most distros that give you a python-pip
or similar package also give you packages for popular packages. If you install them that way, either you won't need python-dev
(and a C compiler), because they're binary packages, or you will need them but they'll be pulled in as a dependency (rpm, deb, etc. all have a way to specify separate "build" and "run" dependencies).
But if you go behind your package manager's back and try to install packages with pip
(which is a reasonable thing to do), the package manager can't tell you which packages need what dependencies, while pip
can only tell you about Python package dependencies, so there's nothing to enforce this.