#include <Python.h>
此代码的错误为'Python.h' file not found
。
我用brew
安装了python,结果如下所示。python的路径已经写入$PATH
MacBook-Pro test % python --version
Python 3.10.8
MacBook-Pro test % brew search python
==> Formulae
app-engine-python python-tk@3.11
boost-python3 python-tk@3.9
bpython python-typing-extensions
gst-python python-yq
ipython python@3.10 ✔
libpython-tabulate python@3.11
micropython python@3.7
ptpython python@3.8
python-build python@3.9
python-gdbm@3.11 reorder-python-imports
python-launcher wxpython
python-lsp-server pythran
python-markdown jython
python-tabulate cython
python-tk@3.10
==> Casks
awips-python mysql-connector-python
If you meant "python" specifically:
It was migrated from homebrew/cask to homebrew/core.
MacBook-Pro test % echo $PATH
/usr/local/opt/python@3.10/libexec/bin:/Users/fanxuezhou/opt/anaconda3/bin:/Users/fanxuezhou/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
如果有人能告诉我如何在Xcode中使用Python.h
,或者我如何通过命令行编译代码?
MacBook-Pro test % gcc main.cpp -o test
main.cpp:9:10: fatal error: 'Python.h' file not found
#include <Python.h>
^~~~~~~~~~
1 error generated.
1条答案
按热度按时间1aaf6o9v1#
我已经通过使用
g++
解决了这个问题,