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?

  • Please post a snippet of the code so we know what we are looking at and a screenshot of the error. Links become broken easily and that one did not contain any of your code, so it's difficult to troubleshoot.
    – MaryBeth
    Mar 7 '16 at 13:27
  • I don't know eclipse with python, but to use any other ide, its a good idea to use a batch file calling %OSGEO4W_ROOT%\bin\o4w_env.bat before starting the ide. Sometimes you may need to use the right PYTHONPATH environment Variable as well. Mar 7 '16 at 13:58
  • I think there is no code, at least in the book it wasn't necessary any code to setup the interpreter to Eclipse. I wasn't trying to compile a code, just setting the preferences. I kind new to this, so I maybe speaking something stupid, sorry. Do you have a exemple of how to config this batch file? Mar 7 '16 at 18:43
  • How do I post a image without adding the link? Mar 7 '16 at 18:45
  • PYTHONHOME is the env var to set and defile the python installation. In this way you can use AutoConfig Mar 18 '16 at 13:08

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

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.


Steps for configure Qgis Python interpreter in Eclipse:

1. Obiusly you need install Qgis for example from Osgeo4W instalator

2. Environments variables (in my case Qgis have instaled in C:\OSGeo4W64

  • Add to PATH : C:\OSGeo4W64\bin;C:\OSGeo4W64\apps\qgis\bin

enter image description here

Create or update :

  • PYTHONHOME - C:\OSGeo4W64\apps\Python27
  • PYTHONPATH - C:\OSGeo4W64\bin;%PATH%

enter image description here

Then open Eclipse (I assume that pydev is installed) and go to interpreter. Window -> Preferences -> PyDev -> Interpreters

3. Remove check with Interpreter:General preferences

enter image description here

4. Go to Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter.

Click New and point to python.exe in OsGeo4W64\bin : C:\OSGeo4W64\bin\python.exe

enter image description here

Add PyQT Libraries if not present in OSGeo4W site-packages.

Add Forced Builtins. In Python Interpreter Window > Forced Builtin Tab -> New. Enter following builtins:

  • PyQt4
  • qgis

enter image description here

And finally click in Apply.

Tested in windows 10 with eclipse neon

  • I had the same problem and I just succesfully tested it in Windows 7 64bits, Eclipse Oxygen. My QGis is 2.18.19 LTR and it is in OSGeo4W64 as well.
    – nanunga
    May 31 '18 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.