GDAL error when installing Geopandas/Fiona in venv isolation mode

I want to switch from using the isolation mode from Docker to venv, so I used the viktor-cli configure command and provided the path to my Python installation. This env contains several packages including Geopandas, which has Fiona as a dependency.

While I encountered no problems using Docker, I get the error below regarding Fiona and GDAL when using venv. The same error pops up when simply installing Geopandas in a regular venv, so it is not necessarily a problem related to VIKTOR, but it does prevent me from the venv isolation mode. Does anyone know a solution for this?

WARNING: you are developing with Python 3.8, while the published app runs on Python 3.7. The Python version of the published app can be specified by setting 'python_version' in the viktor.config.toml file

SDK version: 13.2.1 Connector version: 5.16.0
Creating app specific install dir signals
Creating virtual environment
Looking in indexes:****
Collecting viktor==13.2.1
  Downloading (7.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.7/7.7 MB 9.9 MB/s eta 0:00:00
Collecting viktor-connector==5.16.0
  Downloading (674 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 674.4/674.4 KB 10.7 MB/s eta 0:00:00

Collecting geopandas==0.9.0
  Using cached geopandas-0.9.0-py2.py3-none-any.whl (994 kB)
Collecting pandas<2.0.0,>=0.23.4
  Using cached pandas-1.4.3-cp38-cp38-win_amd64.whl (10.6 MB)
Collecting fiona>=1.8
  Using cached Fiona-1.8.21.tar.gz (1.0 MB)
  Preparing metadata ( ... error
  error: subprocess-exited-with-error

  Γ— python egg_info did not run successfully.
  β”‚ exit code: 1
  ╰─> [1 lines of output]
      A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Exiting because of an error: installation of the app failed

Hi Martijn,

On Windows GDAL needs to be built from source. The error is caused by the fact that not all build dependencies required for this process are correctly set up. You can either try to get everything sorted in order to built the Python package from source or you can use an unofficial distribution as explained in the second bullet of this link: Getting Started - Troubleshooting | VIKTOR Documentation. Please not that you will need to account for the fact that published apps will run on Linux.



Hi Raoul,
I finally found some time to try this out. Unfortunately, I’m getting this error upon installation using the venv isolation mode:

SDK version: 13.2.1 Connector version: 5.17.1
Creating app specific install dir signals
Creating virtual environment
Looking in indexes:
ERROR: GDAL-3.4.3-pp38-pypy38_pp73-win_amd64.whl is not a supported wheel on this platform.
Exiting because of an error: installation of the app failed

My requirements.txt looks like this:

# viktor==13.2.1
openpyxl==3.0.10; platform_system == "Windows"; platform_system == "Windows"

I’ve tried to change platform_system to "Linux" hoping this might solve the problem (as the docs say something about accounting for the fact that the apps run on Linux) but this simply makes the installer ignore the wheels.

Do you have any idea what’s wrong?

Have a look to this thread.

Thanks Mirco, the thread clarified a lot!

Three things were going wrong:

  1. I only defined the installations for Windows, not for Linux.
  2. I tried to directly download the wheels from Gohlke’s website in the requirements.txt, which didn’t work. But downloading them manually to a local subfolder fixed this.
  3. I mistakenly used a PyPy-wheel instead of CPython.

For future reference: my requirements.txt now looks like this. Haven’t tried to publish it yet, but local installation works like a charm.

# viktor==13.2.1
./local-whls/GDAL-3.4.3-cp38-cp38-win_amd64.whl; platform_system == "Windows"
./local-whls/Fiona-1.8.21-cp38-cp38-win_amd64.whl; platform_system == "Windows"
fiona==1.8.21; platform_system != "Windows"
1 Like

Nice!!! I am glad to hear was useful to solve your issues.
For sure the documentation needs to be updated and improved on this topic.

1 Like