I searched all the same questions, and none of them works for me, so i decided to ask this question in addition to those:

I installed QGIS 2.18 via this downloaded setup 'QGIS-OSGeo4W-2.18.11-1-Setup-x86_64.exe'.

and my PATH system variables are :

C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%PYTHONHOME%;%PYTHONHOME%\Scripts;C:\Program Files\QGIS 2.18\bin;%PATH%

my PATH user variables:



C:\Program Files\QGIS 2.18\apps\Python27


C:\Program Files\QGIS 2.18\apps\Python27\Lib

*** I use pycharm and my project interpreter is :

Python 2.7.5 (C:\Program Files\QGIS 2.18\bin\python.exe

now if I import qgis.core it will give

import error: no module named qgis.core

error in pycharm, but no errors in qgis python console!!!

What did I do wrong?

  • i forgot to say my operating system is windows 7,2009 build, sp1
    – Ash
    Sep 21, 2017 at 15:52

1 Answer 1


I found it, it was just a small tricky approach.

in OsGeo4w website says you have to install QGIS by Osgeo4w setup which it sets all kinds of path variables for you ...

( it was NOT entirely true, in my case)

leave your PATH, Path, PYTHONPATH, PYTHONHOME to where it's functional for all modules unless qgis's.

I removed QGIS standalone and installed QGIS via OsGeo4w however. so the path variables that I wrote in the question must change to the same directories but NOT in QGIS 2.18 ROOT, rather in C:\OSGeo4W64.

for example, my PYTHONHOME is now :


and so on...

so I created a whatever.cmd file using notepad, with this information in it :

@echo off


call "%OSGEO4W_ROOT%"\bin\o4w_env.bat

call "%OSGEO4W_ROOT%"\apps\grass\grass-6.4.3\etc\env.bat

@echo off

path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin

path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-6.4.3\lib

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python;

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages


set PATH=C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\bin;%PATH%

start "PyCharm aware of Quantum GIS" /B "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\bin\pycharm64.exe" %*

and saved it to somewhere.

So if you use Qgis standalone just instead of osgeo_root write your qgis_root directory.

the few last line are dedicated to familiarizing all this mess to Pycharm.

be careful of typing mistakes. I learned, one wrong char can mess it up...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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