12

I wanted to set up PyCharm the way this blog post explains: Setting up PyCharm for PyQGIS and Qt.

I did everything as instructed but when it comes to adding project interpreters I got this error message:

Pycharm

Does anyone have a solution to this?

6
  • You wouldn't happen to be mixing 64 and 32 bit versions of QGIS and/or Python?
    – gsherman
    Commented Oct 9, 2014 at 20:35
  • I have 64bit QGIS and I don't know how to check what PyCharm version I have. BTW I got Win7 64bit Commented Oct 10, 2014 at 11:25
  • Take a look at this recent post and see if it provides any hints to your situation: spatialgalaxy.com/2014/10/09/…
    – gsherman
    Commented Oct 10, 2014 at 17:55
  • Thank you very much! It worked by now I search way to remote debugging with pycharm but nothing worked. Commented Oct 12, 2014 at 10:49
  • I had same issue. Check out below url. It helped me discuss.howtogeek.com/t/how-to-install-python-on-windows/20111
    – user84691
    Commented Oct 19, 2016 at 10:05

4 Answers 4

3

From the comments it looked like the asker of this question was able to resolve their problem by reading a blog posting entitled A Quick Guide to Getting Started With PyQGIS on Windows.

In that blog the advice offered seemed to be:

We only changed the last line, adding the start statement with the path to the IDE (PyCharm). If you save this to something like pycharm.cmd, you can double-click on it to start PyCharm. The same method works for other IDEs, such as PyDev.

3

The batch script from the A Quick Guide to Getting Started with PyQGIS on Windows as described in the comments and by @PolyGeo maybe outdated. The SDK seems invalid appear in PyCharm 2016.3 by using the script.

I suspect it needs more paths to be included especially (maybe) pip.exe path that exist in %OSGEO4W_ROOT%\apps\Python27\Scripts. So I include that and all other paths (not sure which one is required, maybe some unnecessary, but no time to test 1 by 1):

@echo off

SET OSGEO4W_ROOT=C:\Program Files\QGIS 2.18
SET PYCHARM="C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\bin\pycharm.exe"

CALL %OSGEO4W_ROOT%\bin\o4w_env.bat
CALL %OSGEO4W_ROOT%\apps\grass\grass-7.0.5\etc\env.bat

path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.0.5\lib

SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\bin
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Scripts
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages
SET PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\DLLs
SET QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis

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

Then it works. Edit the paths to match your environment.

Anyway, the recent how python/conda installation register PATH or PYTHONPATH in my environment, I follow the same for QGIS python paths in the script.

1
  • With PyCharm 2018.3.7, this is what I needed. Thanks.
    – HFBrowning
    Commented Aug 23, 2019 at 20:28
0

I had the same issue: I clicked on "file/Reload all from disk", it works ...

-1

Make sure that the interpreter python.exe is executable if you're on Linux.

PyCharm will show the same error even if interpreter has been set up fine.

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.