Using OSGeo4W to install additional python packages.

26 views
Skip to first unread message

christina...@csiro.au

unread,
Sep 2, 2021, 10:28:45 PM9/2/21
to QGIS Australia User Group
Does anyone have experience in using OSGeo4W to install additional python packages on windows?

Until recently I have been successfully using OSGeo4W command line to install additional python packages using
"%OSGEO4W_ROOT%\bin\osgeo4w-setup.exe" -q -b -A -k -n -s http://download.osgeo.org/osgeo4w/ -P python3-fiona -P python3-geopandas -P python3-rasterio

Since the QGIS installer was compiled as .msi instead of an .exe the above code wants to upgrade/install everything rather than just the package(s) listed. I am getting the same behavior using the GUI as well.

I have an open ticket on OsGeo4W (#689 - https://trac.osgeo.org/osgeo4w/ticket/689) but have had no response.

Can anyone help?

Pedro Camargo

unread,
Sep 2, 2021, 11:42:49 PM9/2/21
to australian-qg...@googlegroups.com
I wrote a blog post about that a little while ago. 

 https://xl-optim.com/adding-python-packages-to-qgis-3-on-windows-10/ 


Cheers, 
Pedro 


---- On Fri, 03 Sep 2021 12:28:45 +1000 christina...@csiro.au wrote ----

--
You received this message because you are subscribed to the Google Groups "QGIS Australia User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to australian-qgis-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/australian-qgis-user-group/cbf6047f-b679-4cce-bd74-9dd5b532cd87n%40googlegroups.com.

christina...@csiro.au

unread,
Sep 3, 2021, 1:44:11 AM9/3/21
to QGIS Australia User Group

Thanks Pedro.

I’ve seen several blogs/forums with that method. Unfortunately, fiona, geopandas and rasterio all need GDAL so installing via PIP doesn't work especially on windows.

The packages I need are all available (and configured for GDAL & QGIS) in OSGeo4W. My plugin users aren't programmers so I'm trying to make the installation easy by writing an installation bat file they can run. I think my issue is related to this warning from the QGIS downloads page and maybe I need to specify a different source site as using the one previously shown, or leaving it out upgrades/installs everything.

QGIS_3.20.1_warning.png

Oh and by the way py3_env as shown in your blog, isn't available in these newer releases.

Cheers,
Christina

Pedro Camargo

unread,
Sep 3, 2021, 1:56:51 AM9/3/21
to australian-qgis-user-group, christinaratcliff
Hi Christina,
                     I just tested installing other packages by starting QGIS as administrator and calling pip through a sub-process and, as you have noticed, the issue is GDAL. The point there is that Fiona must be compiled against GDAL.

One RISKY thing is to get the compiled version of Fiona from Chris Gohlke's website (https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona) and install it directly using your preferred method. 

I just did it and it worked like a charm.

Keep in mind that there is no guarantee of issues between the versions of GDAL used to build QGIS and the one used by Chris.

Cheers,
Pedro





---- On Fri, 03 Sep 2021 15:44:10 +1000 christina...@csiro.au <christina...@csiro.au> wrote ----

--
You received this message because you are subscribed to the Google Groups "QGIS Australia User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to australian-qgis-use...@googlegroups.com.

christina...@csiro.au

unread,
Sep 3, 2021, 3:23:35 AM9/3/21
to QGIS Australia User Group
Hi Pedro,

I've tried pip and wheels in the past and wheels worked well in the QGIS 2 days, but then changes in the wheel/pip fiona, rasterio and geopandas  packages to include GDAL caused problems with Windows or QGIS when trying to use some of the functions. It was suggested in one of those package forums to use OSGeo4W to install the packages to avoid having conflicting GDAL versions installed.

Cheers,
Christina

Reply all
Reply to author
Forward
0 new messages