Zuerst installierte ich Lxml ohne PIP (Python 2.7.2 unter Mac OS 10.6.8). Dann lese ich this post und ich installierte es wieder mit pip (sudo pip install lxml
). Ich hatte immer noch ein Problem:Lxml mit Python auf einem Mac installieren
Ich kann lxml (import lxml
) importieren, aber ich kann from lxml import etree
nicht verwenden. Ich habe diese Fehlermeldung:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so, 2): Symbol not found: _htmlParseChunk
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so
Dann habe ich versucht, folgende these instructions lxml von der Quelle zu installieren, und ich habe diese Fehlermeldung:
checking whether we are cross compiling... configure: error: in `/Users/my_name/Applications/lxml/lxml-2.2.2/build/tmp/libxml2-2.7.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Traceback (most recent call last):
File "setup.py", line 115, in <module>
STATIC_CFLAGS, STATIC_BINARIES),
File "/Users/my_name/Applications/lxml/lxml-2.2.2/setupinfo.py", line 50, in ext_modules
libxslt_version=OPTION_LIBXSLT_VERSION)
File "/Users/my_name/Applications/lxml/lxml-2.2.2/buildlibxml.py", line 198, in build_libxml2xslt
call_subprocess(configure_cmd, cwd=libxml2_dir, **call_setup)
File "/Users/my_name/Applications/lxml/lxml-2.2.2/buildlibxml.py", line 158, in call_subprocess
raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))
Exception: Command "./configure --without-python --disable-dependency-tracking --disable-shared --prefix=/Users/my_name/Applications/lxml/lxml-2.2.2/build/tmp/libxml2" returned code 1
Schließlich folgte ich die zweite Beratung von this answer und ich verwendete die Befehlszeile sudo STATIC_DEPS=true /usr/bin/easy_install-2.7 lxml
. Es installierte lxml auf dem von Apple gelieferten System Python 2.7 und nicht auf der Version, die ich gerade benutze. Der positive Punkt: Wenn ich den Apple-Python starte, kann ich from lxml import etree
.
Negativer Punkt: Ich weiß immer noch nicht, wie ich lxml auf einer anderen Version von Python installieren. Irgendeine Idee?
Ich verwende derzeit /Library/Frameworks/Python.framework/Versions/2.7/bin/python
.
möglich Duplikat [Brauchen lxml auf o Hilfe bei der Installation x 10.7] (http://stackoverflow.com/questions/7961577/need-help-installing-lxml-on-o--x-10-7) – bernie
andere Version von OSX in dieser Frage, aber vielleicht genug da, um Sie in Fahrt zu bringen – bernie
Leider, lxml aus bauen Quelle funktioniert nicht. – Antonin