I have Python on my Ubuntu system, but gcc can't find Python.h

后端 未结 14 1732
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 13:10

I am on a school computer, so I can\'t install anything.

I am trying to create C code which can be run in Python. It seems all the articles I am finding on it requi

相关标签:
14条回答
  • 2020-11-27 13:37

    You need python-dev installed.
    For Ubuntu :
    sudo apt-get install python-dev # for python2.x installs sudo apt-get install python3-dev # for python3.x installs
    For more distros, refer -
    https://stackoverflow.com/a/21530768/6841045

    0 讨论(0)
  • 2020-11-27 13:44

    For Ubuntu 15.10 and Python 3, comming to this question as they don't have Python.h but having administrative rights, the following might solve it:

    sudo apt-get install python-dev
    sudo apt-get install python3-dev
    sudo apt-get install libpython3-dev
    sudo apt-get install libpython3.4-dev
    sudo apt-get install libpython3.5-dev
    
    0 讨论(0)
  • 2020-11-27 13:45

    You need the python-dev package which contains Python.h

    0 讨论(0)
  • 2020-11-27 13:45

    None of the answers worked for me. If you are running on Ubuntu, you can try:

    With python3:

    sudo apt-get install python3 python-dev python3-dev \
         build-essential libssl-dev libffi-dev \
         libxml2-dev libxslt1-dev zlib1g-dev \
         python-pip
    

    With Python 2:

    sudo apt-get install python-dev  \
         build-essential libssl-dev libffi-dev \
         libxml2-dev libxslt1-dev zlib1g-dev \
         python-pip
    
    0 讨论(0)
  • 2020-11-27 13:46

    That means you are not install libraries for python dev.

    If you are on Linux OS, you can solve this issue by commands separately below:

    • Ubuntu (Debian) :

      sudo apt-get install python-dev (Py2) or sudo apt-get install python3-dev (Py3)

    • Rehat (CentOS):

      yum install python-devel

    0 讨论(0)
  • 2020-11-27 13:47

    You have to use #include "python2.7/Python.h" instead of #include "Python.h".

    0 讨论(0)
提交回复
热议问题