[osgeo4w-dev] [osgeo4w] #853: Broken venv created with python-qgis.bat

OSGeo4W trac_osgeo4w at osgeo.org
Fri Nov 8 00:53:47 PST 2024


#853: Broken venv created with python-qgis.bat
----------------------+----------------------------
Reporter:  nicogodet  |       Owner:  osgeo4w-dev@…
    Type:  defect     |      Status:  new
Priority:  normal     |   Component:  Package
 Version:             |  Resolution:
Keywords:             |
----------------------+----------------------------
Comment (by akominlsfi):

 Saw a familiar ticket title, we've had similar issues with our plugin
 development on Windows machines. AFAIK to make qgis python work with
 venvs, it requires some level of patching either to the installation
 directly or to the venv.

 We use only one ltr/non-ltr branch of qgis per osgeo4w install directory,
 so our patching is like this now:
 - copy some dlls from install/bin to install/apps/python3xx/dlls (for
 python to find the stdlib ssl/crypto/sqlite/lzma dlls directly)
 - create .pth with os.add_dll_directory(install/bin) (to make python find
 other possible site-package dlls)
 - create .pth with os.add_dll_directory(install/apps/qt5/bin) (to make
 python find qt dlls)
 - create .pth with os.add_dll_directory(install/apps/qgis/bin) & path for
 install/apps/qgis/python (to make python find qgis dlls and qgis imports)

 This allows us to use the install/apps/python3xx/python.exe directly, it
 has "import qgis" & "import PyQt5" etc usable, and venvs created with
 --system-site-packages also work in the same way.

 Another option would be this tool, that does similar patching to the
 created venvs:

 https://github.com/GispoCoding/qgis-venv-creator

 Previous issues related to this same thing with some more details:

 https://trac.osgeo.org/osgeo4w/ticket/814 (external zlib dll issue that
 crashed the python.exe on launch was fixed)

 https://trac.osgeo.org/osgeo4w/ticket/692
-- 
Ticket URL: <https://trac.osgeo.org/osgeo4w/ticket/853#comment:1>
OSGeo4W <http://trac.osgeo.org/osgeo4w>
OSGeo4W is the Windows installer and package environment for the OSGeo stack.


More information about the osgeo4w-dev mailing list