ImportError: No module named qgis.core - python

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.

Related

Installed module via pip, still get ModuleNotFoundError

I'm trying to use w3af to start doing some routine security testing on a webapp that I'm using. Install instructions recommend cloning a git repo, then running the python code and seeing what dependencies are unmet then installing them. My first run yielded:
ModuleNotFoundError: No module named 'ConfigParser
OK, no problem, right?
$ pip install ConfigParser
Collecting ConfigParser
Downloading configparser-5.2.0-py3-none-any.whl (19 kB)
Installing collected packages: ConfigParser
Successfully installed ConfigParser-5.2.0
Mission accomplished, let's try again!
$ ./w3af_console
Traceback (most recent call last):
File "./w3af_console", line 12, in <module>
from w3af.core.controllers.dependency_check.dependency_check import dependency_check
File "/Users/westonx/bin/w3af/w3af/core/controllers/dependency_check/dependency_check.py", line 26, in <module>
from w3af.core.data.db.startup_cfg import StartUpConfig
File "/Users/westonx/bin/w3af/w3af/core/data/db/startup_cfg.py", line 22, in <module>
import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
Hmmm. Could swear we took care of that. Let's run pip (maybe pip3?) again to be sure?
$ pip3 install ConfigParser
Requirement already satisfied: ConfigParser in /Users/westonx/.pyenv/versions/3.8.2/lib/python3.8/site-packages (5.2.0)
Seems good. Let's check to see if the import path includes that directory:
$ python -c "import sys; print('\n'.join(sys.path)); import ConfigParser;"
/Users/westonx/.pyenv/versions/3.8.2/lib/python38.zip
/Users/westonx/.pyenv/versions/3.8.2/lib/python3.8
/Users/westonx/.pyenv/versions/3.8.2/lib/python3.8/lib-dynload
/Users/westonx/.pyenv/versions/3.8.2/lib/python3.8/site-packages
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ConfigParser'
So... we know the sys.path includes the directory pip says the module is installed in, but when we import it, python insists it's not there.
configparser-5.2.0.dist-info and configparser.py are indeed in my ~/.pyenv/versions/3.8.2/lib/python3.8/site-packages directory, so it doesn't look like pip telling me something that's not true. But it sure looks like python is.
I'm using pyenv on MacOS 10.14, not sure if that makes a difference. Anyone have ideas of what next steps should be?
ConfigParser is a built in library in Python, but its name was changed to configparser in Python 3. It appears like w3af is still using Python 2 (I found this check that actively states it, but you never even got that far). So, to run this code, you need to run it with Python 2.
There are very many (thousands) of python3 compatibility issues with the w3af codebase. The ConfigParser issue is just the first one you hit - the codebase is full of references to outdated / unmaintained libraries, and has no support for python3 byte strings vs. unicode strings (b"" vs ""), which are used throughout the codebase.
There is a w4af project on Github, where someone has made the effort to port all the w3af code to python3, but you didn't hear that from me.

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.

Python third party Module global import

i'm currently into learning a bit of python and i want to import the paperclip third party module into my python file.
Yes, i already installed the pyperclip module with
pip install pyperclip.
if i create a file on my desktop, i get an error which says
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pyperclip
ImportError: No module named pyperclip
However if i put the test.py in my python folder, it runs.
The question now is, is there a way to make all my installed modules available on a global scope ? I just want to have my file e.g. on my Desktop and run it without having import issues.
Thank you.
Greetings
Edit: I'm working on a Mac, maybe this leads to the problem
Found the problem.
The pip installautomatically used pip3.5 install
whereas python test.pydidn't use python3.5 test.py
Thank you #Bakurìu
Is there a way i can define python3.5as python?
You can do this :
pip3.5 install paperclip
pyperclip is install but not paperclip

wxPython import error with Windows install

I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

Categories

Resources