[GIS] How to install networkx python in QGIS

networkxpythonqgis

How to install and how to compile networkx python on QGIS?

I always get an error that no module named networkx in the console of QGIS
I copied the file networkx in C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages and there are not change.

Best Answer

I copied the file networkx

It is not a simple file, it is a folder with many files. You must place the entire unzipped networkx folder in C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages (because it is a simple module)

In general, to use a Python module, you must first install it:

python setup.py install

As on Windows, QGIS uses its own version of Python (not in the Windows's registry), without a Python shell, you can:

  1. use the bootstrapped installer for setuptools of Nathan's QGIS Blog, which will install directly the module into a folder rather than looking in the registry
  2. download the networkx version of Christoph Gohlke at Unofficial Windows Binaries for Python Extension Packages, unzip it (it is a .exe file but you can directly unzip it) and place the resulting folder in C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages.

After that, in the Python console of QGIS:

import networkx
networkx.__file__
'C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages\networkx\__init__.pyc'

or

'C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib\site-packages\networkx-1.7-py2.7.egg\networkx\__init__.pyc'

depending on how you installed the module

Related Question