1

I've been trying to solve an import error I've been getting the whole day and it's just driving me crazy. I've literally went through every Stack Overflow similar question and tried out every single solution and nothing seems to do the magic for me.

I'm currently running a script on my Terminal by doing

$ python camelcamelcamel-import.py

The error I'm getting is:

 Traceback (most recent call last):
 File "camelcamelcamel-import.py", line 1, in <module>
 import sys, mechanize, lxml.html
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/html/init.py", line 54, in <module>
 from .. import etree
 ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/etree.so, 2): Symbol not found: _xsltDocDefaultLoader
 Referenced from:        /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml/etree.so
 Expected in: dynamic lookup

I've tried installing/uninstall the modules, the same thing for pip and nothing seems to work for me.

Any help would be extremely appreciated, thank you!

Taku
  • 31,927
  • 11
  • 74
  • 85
  • `brew install libxml2` ? Possibly: http://stackoverflow.com/a/26544099/2026508 difference in expected versions, etc. – jmunsch Mar 30 '17 at 23:19
  • Reinstall python maybe? – Taku Mar 31 '17 at 00:30
  • @jmunsch I have tried doing so but I still get the exact same error, I don't get it. – Luís Carvalho Mar 31 '17 at 02:39
  • @abccd I was looking to avoid doing so, seems extremely confusing. – Luís Carvalho Mar 31 '17 at 02:39
  • Does installing/using other external modules work? – Taku Mar 31 '17 at 02:42
  • @abccd I haven't tried doing so. I installed python and then using pip installed mechanize and lxml using pip. Now I've installed brew and installed libxml2 and libxslt as recommended. I still get the same error. Which external module would you recommend as an easy install ? Should I use pip or brew ? Thank you. – Luís Carvalho Mar 31 '17 at 02:52
  • Just wondering, how did you installed python? By the official install? or by brew? or compiled from source? – Taku Mar 31 '17 at 03:02
  • And another question recommended this: `pip install lxml --no-use-wheel`, which they claimed to solve the problem but I hadn't tested yet. You will have to uninstall lxml first by `pip uninstall lxml` – Taku Mar 31 '17 at 03:13
  • @abccd I downloaded it from https://www.python.org/downloads/ and installed it. – Luís Carvalho Mar 31 '17 at 03:16
  • @abccd Doing so I got this: DEPRECATION: --no-use-wheel is deprecated and will be removed in the future. Please use --no-binary :all: instead. Requirement already satisfied: lxml in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages – Luís Carvalho Mar 31 '17 at 03:23
  • Did you uninstall it first? And if the warning say so, you can do `pip install lxml --no-binary :all:` instead... – Taku Mar 31 '17 at 03:24
  • Aha, you can check this [this answer](http://stackoverflow.com/a/4213515/6622817) – Taku Mar 31 '17 at 03:32
  • @abccd Yes, I did uninstall it first but got a few errors: http://i.imgur.com/5PW41k7.png – Luís Carvalho Mar 31 '17 at 03:34
  • @abccd After running 'pip install lxml --no-binary :all:' I still got 'Requirement already satisfied: lxml in /Library/Frameworks/Python.framework/Versions/2.7/lib/python‌​2.7/site-packages' – Luís Carvalho Mar 31 '17 at 03:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/139543/discussion-between-luis-carvalho-and-abccd). – Luís Carvalho Mar 31 '17 at 03:37

1 Answers1

0

Reinstall libxslt and libxml2 using brew.

brew install libxslt libxml2

If you see errors during install, execute this:

xcode-select --install
Dmitry Shilyaev
  • 713
  • 4
  • 10