[GIS] Adding QGIS-specific Python interpreter to Eclipse

eclipsepyqgispythonqgis

I was following the steps from QGIS Python Programming CookBook to add qgis interpreter to eclipse, however I went into the following error in step 8:

"See error log for details.
No output was in the standard output when
trying to create the interpreter info for: C:\Program Files\QGIS Essen\bin\python.exe
The error output contains:>>ImportError: No module named site
<<"

Steps from the book:

  1. Open Eclipse.
  2. From the Window menu, select Preferences. On OS X, you must click on the
    Eclipse menu to find the preferences menu.
  3. In the pane on the left-hand side of the Preferences window, click on the plus sign
    next to PyDev.
  4. From the list of PyDev preferences, select Interpreter Python.
  5. In the pane labelled Python Interpreters, click on the New button.
  6. In the Select interpreter dialog, name the interpreter PyQGIS.
  7. Browse to the location of the QGIS Python interpreter called python.exe within the bin folder of the QGIS program folder.

8. When you click on the OK button, Eclipse will attempt to automatically add every Python library it finds to the Python path for this interpreter configuration. We need to control which libraries are added to prevent conflicts. Click on the Deselect All button and then click on OK:

When i click OK button it gives that error.
enter image description here

enter image description here


I going try do detail even futher, since no answer was given. I think that the objective of this feature is to facilitate the coding of python into QGIS program, because the author says:

"The Eclipse IDE with the PyDev plugin is cross-platform, has advanced debugging tools, and is free. This tool makes an excellent PyQGIS IDE. Eclipse allows you to have multiple Python interpreters configured for different Python environments. When you install PyDev, it automatically finds the installed system Python installations. On Windows, you must also add the Python interpreter installed with PyQGIS. On all platforms, you must tell PyDev where the PyQGIS libraries are"

That part of bold is exactly what I a having being try to do. I don't know what more I can do, can I post again to get more visibility?

Best Answer

Quote from the cookbook :

To prepare your environment for using Eclipse in Windows, you should also create a batch file and use it to start Eclipse.

To create that batch file, follow these steps.

Locate the folder where qgis_core.dll resides in. Normally this is C:\OSGeo4W\apps\qgis\bin, but if you compiled your own QGIS application this is in your build folder in output/bin/RelWithDebInfo Locate your eclipse.exe executable. Create the following script and use this to start eclipse when developing QGIS plugins.

 call "C:\OSGeo4W\bin\o4w_env.bat"
 set PATH=%PATH%;C:\path\to\your\qgis_core.dll\parent\folder
 C:\path\to\your\eclipse.exe

End quote

In your case as you have install a standalone version it's in the install folder of Qgis as this :

call "(Qgis install path)\bin\o4w_env.bat"
set PATH=%PATH%;(Qgis install path)\apps\qgis\bin

After setting up your batch file use it (by double click on it) to run eclipse. So your environnement will be set up and eclipse will find everything it needs to run you code.