Error in setting up python interpreter

  • Juan Ignacio

    Juan Ignacio - 2011-12-28

    I am completely new to the python world and I am trying to set up PyDev in Eclipse (windows) so I can access QuantumGIS (Qgis) and gdal libraries also included in the Qgis distribution. I would appreciate any help since I am a bit lost after several trials.

    The problem is that when I tried to set up the python interpreter to the one included \Quantum GIS Wroclaw\bin I get the following error:
    See error log for details.
    No output was in the standard output when trying to create the interpreter info.
    The error output contains:>>'import site' failed; use -v for traceback
    Traceback (most recent call last):
      File "C:\Archivos de programa\Eclipse\plugins\org.python.pydev_2.3.0.2011121518\PySrc\", line 15, in <module>
        import os
    ImportError: No module named os

    My version of Qg is 1.7.3. I do not understand this since PyDev should be compatible with python version from 2.1 and I think the one provided by Qg is 2.5.

    I tried to overcome this problem by using python 3.2 but still it does not find the classes. With this interpreter the PYTHONPATH is:
    \Program Archives\Python32\DLLs
    \Program Archives\Python32\lib
    \Program Archives\Python32
    \Program Archives\Python32\lib\site-packages
    \Program Archives\Quantum Gis Wroclaw\apps\qgis\phython
    \Program Archives\Quantum Gis Wroclaw\apps\qgis\apps\Qt4
    \Program Archives\Quantum Gis Wroclaw\apps\qgis\python\plugins

    Thanks a lot in advance. Hope someone can give a clue.

  • Fabio Zadrozny

    Fabio Zadrozny - 2011-12-28

    If QGis is based on Python 2.5, you should definitely not try to use Python 3.2 to access its libraries (Python 3.x is in no ways backward compatible to Python 2.x).

    So, before attempting to configure it within Eclipse, I'd advise to get it working in a shell so that you know which paths would  need to be in the PYTHONPATH.

    I must say I'm not familiar with QGis, so, it'd be useful if you provide a dir of what's below the \Quantum GIS Wroclaw\ install (basically the directory structure, stating which directory contain files and which directories contain other python files - especially the ones you want to import).

    You can try starting a python interpreter in the command line then doing the import you want (i.e.: say import foo), then, add a folder you 'd expect to be in the PYTHONPATH - in your case something as sys.path.append("\Program Archives\Quantum Gis Wroclaw\apps\qgis\python\plugins") and try to do the "import foo" again until you're able to find which should be the PATHS that are added to the PYTHONPATH.

    Note that on some programs, you can't really access its libraries from outside of the program, only when running inside it (because it needs an environment setup - there's an ebook explaining how to setup for blender in PyDev: so, it might be worth taking a look at it if QGIS itself has that limitation on its libraries).




Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks