导入错误:Mac OSX 10.11 上没有名为 lxml 的模块



我刚刚买了一台装有OSX 10.11 El Capitan的新Mac Book Pro。

我正在为本地开发运行Google App Engine启动器 python,这就是我在日志中看到它达到import lxml时的地方。

"ImportError: No module named lxml"

我按照lxml网站上的说明进行操作

sudo pip install lxml

软件包已安装,但无法在 python 的路径上看到。我在.bashrc.bash_profile中更新了我的路径:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/lib/python2.7/site-packages/:$PATH

然后找到了这篇文章在 Mac OSX (10.11) 上安装 lxml 在带有 pip 的 virtualenv 中

$ STATIC_DEPS=true pip install lxml

它再次安装但找不到。

我什至尝试从源代码编译并安装嵌入macports,但仍然没有运气。

我读到lxml团队对OSX及其过时的库和所有混乱感到沮丧。

更新

关于所做的评论,它不是 app.yaml 库声明,它不太可能是 GAE 特有的问题,因为它似乎更有可能在 python 和 oxs-elcapitan 之间。

我也收到这个不寻常的消息

The directory '/Users/[username]/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

我尝试使用 sudo -H,但这也没有解决路径。

但它确实表明 10.11 中的更改可能是问题的一部分。

AppEngine 使用自己的环境来反映其服务器,并且看不到您在本地安装的库。

若要查看包,它应位于项目的根目录中(app.yaml 所在的位置)。

但是,还有运行时提供库 - 阅读部分"将运行时提供的库与本地开发服务器一起使用",请参阅 https://cloud.google.com/appengine/docs/python/tools/libraries27

可能需要添加到 app.yaml

libraries:
- name: lxml
  version: "2.3.5"
STATIC_DEPS

我不起作用(看起来相关的FTP站点已经关闭?),但这确实起到了作用:

C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2:$C_INCLUDE_PATH点安装 lxml

最新更新