我的Ubuntu系统上有Python,但gcc无法找到Python.h [英] I have Python on my Ubuntu system, but gcc can't find Python.h

查看:426
本文介绍了我的Ubuntu系统上有Python,但gcc无法找到Python.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正尝试创建可以在Python中运行的C代码。看起来我发现的所有文章都要求你使用

  #include< Python.h> 

我这样做,但是当我编译它时抱怨没有这样的文件或目录。



计算机有Python(至少它在终端中有 python 命令,我们可以运行任何我们想要的Python代码)。



我在终端中键入 locate Python.h ,但它没有发现任何东西。



我有两个问题:


  1. 我编写的C代码可以在Python中调用,而不需要 Python.h

  2. 我缺少一些东西,并且计算机实际上有 Python.h



需要包含 Python.h python-dev p>

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 require you to use

#include <Python.h>

I do this, but when I compile it complains that there is no such file or directory.

The computer has Python (at least it has the python command in the terminal, and we can run whatever Python code we want).

I typed in locate Python.h in the terminal, but it found nothing.

I have two questions:

  1. Can I write C code that I can call in Python without Python.h?

  2. Am I missing something, and the computer actually has Python.h?

解决方案

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

这篇关于我的Ubuntu系统上有Python,但gcc无法找到Python.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆