gpt4 book ai didi

python - 在 Mac 上安装 lxml 时出现问题,它安装但找不到模块

转载 作者:太空狗 更新时间:2023-10-29 21:30:04 27 4
gpt4 key购买 nike

代码

from lxml import etree 

产生错误

ImportError: No module named lxml 

运行

sudo easy_install lxml

结果

lxml 2.2.7 is already the active version in easy-install.pth 
Removing lxml-2.2.7-py2.5-macosx-10.3-i386.egg from site-packages and rerunning sudo easy_install lxml results in
Adding lxml 2.2.7 to easy-install.pth file
Installed /Library/Python/2.5/site-packages/lxml-2.2.7-py2.5-macosx-10.3-i386.egg
Processing dependencies for lxml
Finished processing dependencies for lxml

但我仍然没有名为 lxml 的模块

为了在我的 Mac (OSX 10.5) 上使用 lxml,我错过了什么步骤?

更新

python --version 报告

Python 2.5.2

运行 python 产生

Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin

最佳答案

您似乎正在尝试将 easy_install lxml 放入 Apple 为 OS X 10.5 提供的 Python 2.5,但使用的鸡蛋可能是用 python.org Python 2.5 构建的。如果您在系统上同时安装了这两者,请记住您需要为每个 Python 单独安装一个 easy_install(setuptools 或 Distribute)。 Apple 在 /usr/bin 中为其 Python 提供了一个。确保您使用的是 python.org(检查 which python),您应该按照 setuptools 或 Distribute 的安装说明为其安装 easy_installeasy_install 将位于 python.org 框架的 bin 目录中:/Library/Frameworks/Python.framework/Versions/2.5//bin。使用 easy_install 安装 lxml;然后它应该自动在 /Library/Frameworks/Python.framework/Versions/2.5/lib 中结束。有类似问题更详细的讨论herehere .

关于python - 在 Mac 上安装 lxml 时出现问题,它安装但找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3624779/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com