英文:
lxml fails to import, with error `symbol not found in flat namespace '_xsltDocDefaultLoader'`
问题
With the code:
from lxml.etree import HTML, XML
I get the traceback:
Traceback (most recent call last):
File "/Users/username/code/project/lxml-test.py", line 3, in <module>
from lxml.etree import HTML, XML
ImportError: dlopen(/Users/username/.virtualenvs/project-venv/lib/python3.11/site-packages/lxml/etree.cpython-311-darwin.so, 0x0002):
symbol not found in flat namespace '_xsltDocDefaultLoader'
I'm on a mac m1 chip.
I installed libxml2 and libxslt via brew.
I'm running python 3.11 inside of a virtualenv.
What I've tried:
- Uninstalling and re-installing lxml with pip, and tried several different versions. (4.7.1 & 4.8.0 didn't compile. All of the 4.9.0,1,2 versions give me the above error)
- Installing libxml2 and libxslt via brew and then reinstalling python-lxml.
- Installing python-lxml via conda (as suggested here)
EDIT:
I posted this bug in lxml's bug report forum, and was notified that this is a highly-duplicated bug report of Missing wheel for macos with M1 Edit.
英文:
With the code:
from lxml.etree import HTML, XML
I get the traceback:
Traceback (most recent call last):
File "/Users/username/code/project/lxml-test.py", line 3, in <module>
from lxml.etree import HTML, XML
ImportError: dlopen(/Users/username/.virtualenvs/project-venv/lib/python3.11/site-packages/lxml/etree.cpython-311-darwin.so, 0x0002):
symbol not found in flat namespace '_xsltDocDefaultLoader'
I'm on a mac m1 chip.
I installed libxml2 and libxslt via brew.
I'm running python 3.11 inside of a virtualenv.
What I've tried:
- Uninstalling and re-installing lxml with pip, and tried several different versions. (4.7.1 & 4.8.0 didn't compile. All of the 4.9.0,1,2 versions give me the above error)
- Installing libxml2 and libxslt via brew and then reinstalling python-lxml.
- Installing python-lxml via conda (as suggested here)
EDIT:
I posted this bug in lxml's bug report forum, and was notified that this is a highly-duplicated bug report of Missing wheel for macos with M1 Edit
答案1
得分: 1
我最近在尝试在装有M1 Pro芯片的笔记本上的3.9虚拟环境中安装python-docx
模块时遇到了类似的问题。
这个答案帮助我解决了我的问题:https://stackoverflow.com/questions/54127779/unable-to-install-python-docx-macos
基本上,你需要先使用pip在你的虚拟环境中安装setuptools,然后再尝试使用pip安装lxml:
pip install -U setuptools
希望这有所帮助。
英文:
I ran into a similar issue recently while trying to install the python-docx
module within a 3.9 virtualenv on my laptop with the M1 Pro chip.
This answer helped solve my issue: https://stackoverflow.com/questions/54127779/unable-to-install-python-docx-macos
Basically, you'd need to install the setuptools with pip within your virtualenv first and then try to install lxml with pip:
pip install -U setuptools
I hope this helps.
答案2
得分: 1
我通过克隆lxml、构建它,并通过以下方式安装解决了我的问题:
pip install -e /path/to/lxml
英文:
I solved my problem by cloning lxml, building it, and installing it via
pip install -e /path/to/lxml
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论