0

I set up a batch file to launch pycharm on Windows in accordance with https://qtibia.ro/2016/06/09/how-to-setup-pycharm-for-qgis-development-under-linux-and-windows/

@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W64
SET PYCHARM="C:\Program Files\JetBrains\PyCharm Community Edition 2018.2\bin\pycharm.exe"

call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass-7.4.0\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.4.0\lib

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

start "PyCharm aware of QGIS" /B %PYCHARM% %*

Pycharm recognizes the OSGeo4W64 python interpreter but qgis.core is still not importable. These are the paths that are recognized by the interpreter:
enter image description here

I tried to change the batch file in accordance with: http://spatialgalaxy.net/2014/10/09/a-quick-guide-to-getting-started-with-pyqgis-on-windows/ and https://nathanw.net/2014/05/10/setting-up-pycharm-for-pyqgis-and-qt/ but then the OSGeo4W64 python interpreter was not recognized. I also tried adding additional paths and installing available packages through pycharm but so far nothing has worked. The error message that I'm receiving when running my code reads as follows: enter image description here

  • Which version of qgis do you use? In case of QGis3 some things changed. – Andreas Müller Jul 26 '18 at 20:52
  • This QGIS 3.0 related answer might help you: gis.stackexchange.com/a/289964/35561 – Mr. Che Jul 27 '18 at 4:29
  • I'm actually using QGIS 2.18. I have come to notice that pycharm was installed in the program folder and not in the program (x64) folder even though I chose the 64 bit version. Could that be the problem? – hdi Jul 27 '18 at 12:50

Your Answer

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

Browse other questions tagged or ask your own question.