3

I have Anaconda Python environment with different packages required for developing a QGIS plugin (including the Plugin Builder Tool etc.).

(qgsdata) C:\TempDaten\_dev\QgsData>conda info

     active environment : qgsdata
    active env location : C:\TempDaten\Programme\Anaconda3\envs\qgsdata
            shell level : 1
       user config file : C:\Users\taras\.condarc
 populated config files : C:\Users\taras\.condarc
          conda version : 4.12.0
    conda-build version : 3.20.5
         python version : 3.8.5.final.0
       virtual packages : __win=0=0
                          __archspec=1=x86_64
       base environment : C:\TempDaten\Programme\Anaconda3  (writable)
      conda av data dir : C:\TempDaten\Programme\Anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\TempDaten\Programme\Anaconda3\pkgs
                          C:\Users\taras\.conda\pkgs
                          C:\Users\taras\AppData\Local\conda\conda\pkgs
       envs directories : C:\TempDaten\Programme\Anaconda3\envs
                          C:\Users\taras\.conda\envs
                          C:\Users\taras\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.12.0 requests/2.24.0 CPython/3.8.5 Windows/10 Windows/10.0.19041
          administrator : False
             netrc file : None
           offline mode : False

How can I extend it with PyQGIS and PyQt?

My technical propriety:

  • Window 10 Enterprise Version 1909
  • PyCharm 2020.3.3 (Community edition) in C:/TempDaten/Programme/PyCharm Community Edition 2020.3.3
  • QGIS 3.22.5-Białowieża in C:/Program Files/QGIS 3.22.5
  • Anaconda3 2020.11 in C:/TempDaten/Programme/Anaconda3

I tried approaches offered in these articles:

But nothing useful. I can not understand how to bring and merge together already existing Python environment in Anaconda with PyQGIS and PyQt.

I could run the created 'pycharm_qgis.bat' file with the following settings:

@echo off 
@ECHO OFF 

set OSGEO4W_ROOT=C:\Program Files\QGIS 3.22.5

@echo off
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"

@echo off
path %OSGEO4W_ROOT%\apps\qgis-ltr\bin;%PATH%

set GDAL_FILENAME_IS_UTF8=YES

set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000

set QGISNAME=qgis

set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis-ltr\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins

set PYCHARM="C:\TempDaten\Programme\PyCharm Community Edition 2020.3.3\bin\pycharm64.exe"

set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis-ltr\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python39
set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python39\lib\site-packages;%PYTHONPATH%

set QT_QPA_PLATFORM_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\Qt5\plugins\platforms
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis-ltr

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

and see the QGIS Python Interpreter in PyCharm:
pycharm

A simple command from qgis.core import * works.

result

0

Your Answer

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

Browse other questions tagged or ask your own question.