Import Error - (Python 2.7) - python

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!

Reinstall libxslt and libxml2 using brew.
brew install libxslt libxml2
If you see errors during install, execute this:
xcode-select --install

Related

Python 3.6.8 - Jedi - ImportError: cannot import name 'traverse_parents'

<TL;DR>
When running import jedi in python 3.6.8 I get the following import error (see end of post for full traceback):
...
from jedi.common import traverse_parents
ImportError: cannot import name 'traverse_parents'
</TL;DR>
I checked in ~/.local/lib/python3.6/site-packages/jedi/common.py : There's a function called traverse_parents alright so there's definitely some witchery at work. Not the first time I've run into one of those "undefined name" problems, but I'm running out of ideas on this one.
Already tried :
uninstalling, reinstalling, upgrading the "jedi" package for pip3
pretty much the same jazz for a couple other packages with "jedi" in their names
upgrading pip3 to 20.2.1 and redoing the same reinstalling routine
installing jedi for python2 because why not (hey, it works fine in python2 but who cares)
also tried installing python-jedi from apt-get (I removed it afterwards)
incantations to ancient Babylonian demons (to no avail, they don't work Sundays)
Vague clues on how I might fix it :
getting the latest version of jedi from github and somehow installing it without making a mess (fat chance)
uninstalling jedi and reinstalling it from within Neovim (hey that might achieve the previous point)
I've scoured the web for the answer to this problem but I'm getting nowhere. Has anyone experienced something similar and managed to solve it ?
Any suggestion welcome.
The full traceback :
Error detected while processing function provider#python3#Call:
line 18:
Error invoking 'python_execute' on channel 5 (python3-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/vee/.local/lib/python3.6/site-packages/jedi/__init__.py", line 32, in <module>
from jedi.api import Script, Interpreter, set_debug_funcion, \
File "/home/vee/.local/lib/python3.6/site-packages/jedi/api/__init__.py", line 24, in <module>
from jedi.api import classes
File "/home/vee/.local/lib/python3.6/site-packages/jedi/api/classes.py", line 26, in <module>
from jedi.inference import imports
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/__init__.py", line 70, in <module>
from jedi.inference import imports
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/imports.py", line 24, in <module>
from jedi.inference import sys_path
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/sys_path.py", line 8, in <module>
from jedi.common import traverse_parents
ImportError: cannot import name 'traverse_parents'
Fixed it :
I reinstalled the latest version of jedi via pip with this command :
pip3 install -e git://github.com/davidhalter/jedi.git#egg=jedi
Now, the command import jedi doesn't generate any exception and it seems to work alright in Neovim.
The reason why the default version installed with pip3 install jedi generated that ImportError is beyond what I can guess. Maybe this version was faulty itself, maybe some quirk of my python environment...
Edit: According to David Halter in the comment below, it seems to be a pip bug
Anyway. If you have the same problem, try this fix.

ImportError using pyside

I need to use QT and pyside for a school project so hope to install pyside on my computer.
I struggled a little bit to install pyside and I eventually got pyside 1.2.4 installed using pip on both python 2.7 and 3.4.
However when I tried to use pyside-uic or import PySide.QtCore I got this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Library not loaded: #rpath/libpyside-python2.7.1.2.dylib
Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so
Reason: image not found
I have been working on this for hours and tried to reinstall with macport.
I also tried to link QtCore.framework from other directory using:
ln -vis /usr/local/Cellar/qt/4.8.7_2/lib/QtCore.Framework /Library/Python/2.7/site-packages/PySide/QtCore.Framwork
nothing worked out and I'm still getting the same error.
Please help and thank you guys so much.
Did you try to set DYLD_LIBRARY_PATH ?
export DYLD_LIBRARY_PATH=/Users/you/virtualenv/lib/python2.7/site-packages/PySide
See here : https://github.com/PySide/PySide/issues/129

python help('modules') returns ImportError

Recently, (I have no idea when), I installed this package called pymol. Today when I was trying to copy a list of all my install modules, I encountered this error.
~/Projects$ python -c "help('modules')"
Please wait a moment while I gather a list of all available modules...
Error: unable to initalize the pymol.cmd module
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pymol/cmd.py", line 117, in <module>
from chempy import io
ImportError: cannot import name io
I've tried
sudo pip uninstall pymol
This definitely worked... but it also definitely did not work. It removed the .egg, and pip list tells me it's not installed, but the tool is still there. I open a python prompt and import it with no problem. Now my question is, if I just delete the package, is there anything that could go wrong, (WCS I'm thinking kafkaesque broken dependency fixing for the rest of my natural life.) and is there a standardized, best practice to remove this, or any other package manually.

Cannot use MySQLdb in python (newbie)

After downloading MySQLdb from sourceforge here, I ran setup.py to install it. Now when I try to import "MySQLdb" I get the following error:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so
Reason: image not found
I'm new to python so I'm not really sure what this means. Can anybody help me figure out how to alleviate this error? Thank you!!!
You need the mysql client library to build MySQLdb. The easiest way that I know of to install it in Mac OS X is to get homebrew and then install mysql with:
brew install mysql
Extra bonus - you can easily install python 3 using brew as well.

ImportError: No module named qgis.core

I am on Ubuntu 13.04. I get the following error message -
Traceback (most recent call last):
File "analyse.py", line 1, in <module>
from log import shelve
File "/home/shubham/SMART/TaxiData/log.py", line 27, in <module>
from demo import *
File "/home/shubham/SMART/zones/demo.py", line 5, in <module>
from qgis.core import *
ImportError: No module named qgis.core
Actually, everything was working fine till today morning. I guess this might be due to a package update.
I tried looking around on Google but my search was fruitless. So, I will really appreciate any help or pointers you guys can give :)
Thanks.
I solved the problem by completely removing the installation and using the nightly builds at 'deb http://qgis.org/debian-nightly raring main'.
If you have pip installed you could either try pip search qgis or pip freeze. The latter shows a list of all installed python packages to check if you have the package. Maybe try reinstalling qgis ...
Try sudo apt-get install python-qgis . The package does not appear to be available on PyPI, but it was listed as "python-qgis" in the Ubuntu packages.

Categories

Resources