Note that there are some explanatory texts on larger screens.

plurals
  1. POInstalling lxml with python on a mac
    primarykey
    data
    text
    <p>First, I installed lxml without using pip (Python 2.7.2 on Mac OS 10.6.8). Then, I read <a href="https://stackoverflow.com/questions/9501894/importerror-after-install-of-lxml-on-os-x-10-6-8">this post</a> and I installed it again using pip (<code>sudo pip install lxml</code>). I still had a problem:</p> <p>I can import lxml (<code>import lxml</code>) but I cannot use <code>from lxml import etree</code>. I have this error message:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; 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 </code></pre> <p>Then, I tried to install lxml from source following <a href="http://lxml.de/build.html#building-lxml-on-macos-x" rel="nofollow noreferrer">these instructions</a>, and I have this error message:</p> <pre><code>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 &lt;module&gt; 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 </code></pre> <p>Finally, I followed the second advise of <a href="https://stackoverflow.com/a/7961663/762435">this answer</a> and I used the command line <code>sudo STATIC_DEPS=true /usr/bin/easy_install-2.7 lxml</code>. It installed lxml on the Apple-supplied system Python 2.7, and not on the version I'm currently using. The positive point: if I run the Apple-Python, I can <code>from lxml import etree</code>.</p> <p>Negative point: I still don't know how to install lxml on another version of python. Any idea?</p> <p>I'm currently using <code>/Library/Frameworks/Python.framework/Versions/2.7/bin/python</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload