Python, C++ & Sublime Text 2: Python.h: 没有这样的文件或目录
Python, C++ & Sublime Text 2: Python.h: No such file or directory
想用一些python扩展我的c++。
文件正在构建:
#include <Python.h>
错误:[DIR]:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
我正在使用sublime text 2来构建我的代码
sudo apt-get install python-dev
locate Python.h
/usr/include/python2.7/Python.h
^python dev是最新的
发现一些谷歌链接谈论包括构建路径或其他东西,但这不是我的强项
-I/usr/include/python2.7/
尝试将此添加到c++中的构建命令中。软件包下的Sublime-text文件,但却破坏了构建系统。救命,我是一个无知的小男人
在Sublime-Text/Packages/c++(可以通过preferences->browse Packages -> c++找到)中编辑名为c++ .sublime-build的文件。在'cmd'行:
UBUNTU"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"]
添加'-I/usr/include/python2.7 -lpython2.7'如下(/usr/include/python2.7是Python.h目录)
"cmd": ["g++", "-I/usr/include/python2.7", "${file}", "-lpython2.7", "-o", "${file_path}/${file_base_name}"]
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"]
添加'-I/Python27/include'如下(/Python27/include是Python.h目录)
"cmd": ["g++", "${file}", "-I/Python27/include", "-L/Python27/libs", "-lpython27", "-o", "${file_path}/${file_base_name}"]
保存,你就可以"增压"你的代码了;)
注意:我对建筑代码之类的东西很糟糕,所以这可能不是解决问题的最优雅的方法
相关文章:
- 是否可以使用 libclang python 解析 cpp 文件中没有标头的函数原型
- 为什么我无法打开/读取从 Python 调用的 C 扩展名中的 txt 文件?
- 从 Python 调用 c++ 文件
- 是否可以使用 Python csv 阅读器读取使用 C++ std::setw 生成的文件?
- 访问 Python 内部的C++文件
- NS3 - python.h 文件无法定位编译错误
- 如何将二进制文件头示例代码 (C++/C#) 转换为 Python?
- 在 c++ 中逐行读取文件(将代码从 Python 转换为 C++)
- 将数据从 c++ 文件连续发送到 Python 脚本以进行进一步处理
- 如何使用c ++代码来调用和运行一个现有的python文件?
- 使用C++,如何在Qt Designer中运行python文件
- 如何在python文件中访问c ++头文件(.py)
- 如何在C++环境中使用 Tensorflow 库调用 python 文件
- 当C 和Python文件不在同一文件夹时,我该如何导入Pybind11上的Python脚本
- SWIG:如何将 python 文件合并到 swig 生成的最终模块文件中
- 提升 Python 如何在导入的 Python 文件中导入 py
- 解析python文件时出现令人烦恼的Ctrl+M问题
- 如何在c++中运行Python文件
- 如何从Python文件内部导入Boost.Python
- 如何通过Boost从python文件导入函数.蟒蛇