[GIS] ImportError: No module named qgis.core from PyQGIS

pyqgis

Trying to load QGIS —

I have a working copy of Python: 2.7.9 — It looks like QGIS is not finding PyQGIS.

I am aware that this is a problem with the PATH but do not see how to fix it.

 > My OS: Debian GNU/Linux 7 (wheezy)

I got a warning when I issued the "apt-get update" command

W: GPG error: http://qgis.org wheezy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3FF5FFCAD71472C4

When I launch the application ("~> qgis") I get two warnings

Warning: loading of qgis translation failed [/usr/share/qgis/i18n//qgis_en_US]

Warning: loading of qt translation failed [/usr/share/qt4/translations/qt_en_US]

and a window with the following info:

Couldn't load PyQGIS.

Python support will be disabled.
Traceback (most recent call last):
File "", line 1, in

ImportError: No module named qgis.core

Python version:
2.7.3 (default, Mar 13 2014, 11:26:58)
[GCC 4.7.2]

QGIS version:
2.10.0-Pisa 'Pisa', exported

Python path:
['/usr/share/qgis/python', u'/home/cjohnson/.qgis2/python', u'/home/cjohnson/.qgis2/python/plugins', '/usr/share/qgis/python/plugins', '/usr/local/anaconda/lib/python2.7/site-packages/pyxnat-0.9.5.3-py2.7.egg', '/usr/local/anaconda/lib/python2.7/site-packages/VTK-6.0-py2.7.egg', '/usr/local/anaconda/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg', '/usr/local/anaconda/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg', '/usr/local/anaconda/lib/python2.7', '/usr/local/anaconda/lib/python2.7/plat-linux2', '/usr/local/anaconda/lib/python2.7/lib-tk', '/usr/local/anaconda/lib/python2.7/lib-old', '/usr/local/anaconda/lib/python2.7/lib-dynload', '/usr/local/anaconda/lib/python2.7/site-packages', '/usr/local/anaconda/lib/python2.7/site-packages/PIL', '/usr/local/anaconda/lib/python2.7/site-packages/Sphinx-1.2.3-py2.7.egg', '/usr/local/anaconda/lib/python2.7/site-packages/runipy-0.1.1-py2.7.egg']

Best Answer

I think that the problem is with your old Debian version (wheezy). You should upgrade to jessie.

This is my /etc/apt/sources.list (including QGIS repository):

deb http://ftp.fr.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

# jessie-updates, previously known as 'volatile'
deb http://ftp.fr.debian.org/debian/ jessie-updates main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ jessie-updates main contrib non-free

#QGIS
deb     http://qgis.org/debian jessie main
deb-src http://qgis.org/debian jessie main

After saving, in bash console as root:

wget -O - http://qgis.org/downloads/qgis-2015.gpg.key | gpg --import
gpg --fingerprint 3FF5FFCAD71472C4  #to avoid GPG error
apt-get update
apt-get upgrade

My upgrading involved more than 3000 files several months ago and it was successfully (but I do not guarantee the same in your system). You have to wait a while (more than 1 hour).

After upgrading you should have the problem solved.

Related Question