[Cython] Suggested action for "Python.h not found"

Abdeali Kothari abdealikothari at gmail.com
Wed Jun 8 02:28:30 EDT 2016


Hi,

Currently, when a user installs cython, if the Python headers are not
found, an error message saying "Python.h: no such file or directory" is
shown (Example: https://justpaste.it/v0gz). Would it be possible to suggest
an action to install the headers ?

I found http://trac.cython.org/ticket/247 which is quite old, and makes the
error message easier to find, but doesn't recommend a solution.

`sys.platform`, `platform.linux_distribution` or `distro`[1] can be used to
find which OS, platform, etc is and use that to suggest a command like:

    if sys.version_info < (3, ) and sys.platform.startswith("linux") and
platform.linux_distribution()[0] in ("ubuntu", "debian"):
        print("Python headers were not found. On Debian/Ubuntu, `sudo
apt-get install python-dev` should install the Python headers.")

    elif sys.version_info < (3, ) and sys.platform.startswith("linux") and
platform.linux_distribution()[0] in ("ubuntu", "debian"):
        print("Python headers were not found. On Debian/Ubuntu, `sudo
apt-get install python3-dev` should install the Python3 headers.")

This would help so that non-developers can use cython based packages easily
as it provides helpful instructions on what to do. Currently, you
essentially search for the error message and go to one of the forums/blogs
explaining what can be done.

Or maybe by default it can just point the user to an Installation Page
which explains in detail what needs to be done to get those headers for
various systems ?

[1] - https://pypi.python.org/pypi/distro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20160608/1c505b35/attachment.html>


More information about the cython-devel mailing list