Toblerity / Fiona

Fiona reads and writes geographic data files
https://fiona.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.15k stars 201 forks source link

ModuleNotFoundError: No module named 'fiona._env' #1438

Closed ajolma closed 1 week ago

ajolma commented 2 weeks ago

Expected behavior and actual behavior.

import fiona works

import fiona does not work

Steps to reproduce the problem.

I have a docker image FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal which has fresh python 3.12.5, proj 9.4.1, geos 3.12.2 and gdal 3.9.2 built from source and installed. The GDAL python bindings are installed and work.

I run the container, get https://github.com/Toblerity/Fiona/archive/refs/tags/1.9.6.tar.gz and issue pip3.12 install . which does not report any problems and says

Successfully installed attrs-24.2.0 certifi-2024.8.30 click-8.1.7 click-plugins-1.1.1 cligj-0.7.2 fiona-1.9.6 six-1.16.0

I can import gdal bindings but I can't import fiona:

bash-5.2# LD_LIBRARY_PATH=/usr/local/lib64/ python3.12
Python 3.12.5 (main, Sep  2 2024, 05:13:11) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>> import fiona
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/build/Fiona-1.9.6/fiona/__init__.py", line 41, in <module>
    from fiona._env import (
ModuleNotFoundError: No module named 'fiona._env'

fiona._env seems to exist (I'm not really familiar with these):

bash-5.2# ls -l /usr/local/lib/python3.12/site-packages/fiona
total 10556
-rw-r--r-- 1 root root   15257 Sep  2 07:45 __init__.py
drwxr-xr-x 2 root root    4096 Sep  2 07:45 __pycache__
-rw-r--r-- 1 root root     733 Sep  2 07:45 _cpl.pxd
-rw-r--r-- 1 root root     229 Sep  2 07:45 _csl.pxd
-rwxr-xr-x 1 root root 1283816 Sep  2 07:45 _env.cpython-312-x86_64-linux-gnu.so
-rw-r--r-- 1 root root     382 Sep  2 07:45 _env.pxd

Operating system

Linux

Fiona and GDAL version and provenance

See above

sgillies commented 1 week ago

The current directory is always on the python path. The file /build/Fiona-1.9.6/fiona/__init__.py tells me that you've launched the Python interpreter from /build/Fiona-1.9.6. The source distribution is unpacked there, but the package isn't actually installed there. If I'd been smart and put Fiona's source files in a src directory, this wouldn't happen. That's something I'll change in a future release.