【问题标题】:CPython Python.h on macOSmacOS 上的 CPython Python.h
【发布时间】:2019-07-11 20:24:22
【问题描述】:

我正在尝试为 macOS 上的 Python3 扩展编译 C++ 代码,并且只有在 #include "$HOME/anaconda3/include/python3.6m/Python.h 时才能编译。有没有办法#include <Python/Python.h> 并让“包含”引用 anaconda Python.h 而不是系统 Python.h?

【问题讨论】:

    标签: macos python c++


    【解决方案1】:

    将您的 Python.h 放在名为 python3.6m 的目录中会有点尴尬,但这里有两种可能的解决方法:

    1. 将目录从 python3.6m 重命名为 Python,然后将参数 -I$HOME/anaconda3/include 添加到编译行,以告诉编译器解析从该文件夹开始的包含路径。

    2. 或者,您可以添加一个符号链接,以便可以通过两个不同的名称访问 python3.6m 目录,例如:

      cd ~/anaconda3/include ; ln -s python3.6m Python

    ...然后将参数 -I$HOME/anaconda3/include 添加到您的编译器参数中(与步骤 1 相同)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      • 1970-01-01
      • 2012-09-04
      • 2020-11-04
      • 2020-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多