原因:swig C++ 代码转 python
运行命令:
gcc -c -fpic example.c example_wrap.c -I/usr/local/include/python2.0
报错如下:
example_wrap.c:154:21: fatal error: Python.h: No such file or directory
compilation terminated.
因此,我需要找到自己 Linux 服务器的 可用 Python.h
(方法一)找到 系统 python 下的 Python.h
# 去系统下发现可用 Python
cd /usr/include/
find | grep python
# 可以发现这里有 python2.7 和 python3.5
drwxr-xr-x 2 root root 12288 Aug 10 2018 python2.7/
lrwxrwxrwx 1 root root 10 Nov 29 2017 python3.5 -> python3.5m/
drwxr-xr-x 2 root root 4096 Feb 2 2018 python3.5m/
cd /usr/include/python3.5
# 就可以发现 Python.h 文件
find | grep Python.h
# 输出如下
./Python.h
- 然后正确执行代码(安排Python):
gcc -c -fpic example.c example_wrap.c -I/usr/include/python3.5
便可以顺利完成转化了(该任务可能和您的不一样呢);
(方法二)到 Anaconda3 目录下 寻找含有 Python.h 的 环境
cd /home/moli/anaconda3
~/anaconda3$ find | grep Python.h
./envs/torch11/include/python3.7m/Python.h
./envs/nice/include/python3.6m/Python.h
./envs/n2n366/include/python3.6m/Python.h
./envs/pix2pix/include/python3.6m/Python.h
./envs/tf20/include/python3.6m/Python.h
./include/python3.6m/Python.h
- 使用 conda 下的 Python
gcc -c -fpic example.c example_wrap.c -I/home/moli/anaconda3/include/python3.6m
2万+

被折叠的 条评论
为什么被折叠?



