question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular imports for Python 3.8 on Windows if DLLs are already loaded

See original GitHub issue

WIth fiona 1.8.15, the issue is fixed now in the conda-forge builds, only the Windows py3.8 build is still failing: https://github.com/conda-forge/fiona-feedstock/pull/167

The failure is with the general error message of partially initialized module, so doesn’t give much pointers (at least to me):

running run_test.py
Traceback (most recent call last):
  File "D:\bld\fiona_1599200296823\test_tmp\run_test.py", line 6, in <module>
    import fiona
  File "D:\bld\fiona_1599200296823\_test_env\lib\site-packages\fiona\__init__.py", line 84, in <module>
    import fiona._loading
  File "D:\bld\fiona_1599200296823\_test_env\lib\site-packages\fiona\_loading.py", line 44, in <module>
    import fiona.ogrext
  File "fiona/ogrext.pyx", line 29, in init fiona.ogrext
  File "D:\bld\fiona_1599200296823\_test_env\lib\site-packages\fiona\env.py", line 14, in <module>
    with fiona._loading.add_gdal_dll_directories():
AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)

_Originally posted by @jorisvandenbossche in https://github.com/Toblerity/Fiona/issues/941#issuecomment-686982973_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:45 (16 by maintainers)

github_iconTop GitHub Comments

8reactions
fargiolascommented, Mar 25, 2021

Probably a different bug, but I’m seeing a similar circular import error when I import geopandas (fiona 1.18.18, geopandas 0.9.0, gdal 3.2.2, installed with pip and brew on macos). The error goes away if I import fiona before geopandas.

7reactions
ogelincommented, Mar 25, 2021

Hi, on MacOS using pip installs I also had this error when importing geopandas. Python 3.9.2.

I changed pyproj from 3.0.1 to 3.0.0 and now the error goes away as long as I import fiona before geopandas.

If I only import geopandas without fiona first, I still get the “Circular import” error message that others reported.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Loading dll from Python 3.8 pyd on Windows with ...
dll from site-packages and the name of the package, os.listdir() shows the package is present. I then call os.add_dll_directory() on that path, ...
Read more >
Unable to import module due to python unable to resolve ...
The most correct fix is to put your DLL alongside your .pyd file. But I suspect in your case, the DLLs can't be...
Read more >
Fiona - PyPI
A circular import introduced in some cases in 1.8.15 has been fixed (#945). ... Load GDAL DLL dependencies on Python 3.8+ / Windows...
Read more >
problem with python numpy - MATLAB Answers
likely you are trying to import a failed build of numpy. ... Original error was: DLL load failed: Das angegebene Modul wurde nicht...
Read more >
Yet another solution to dig you out of a circular import hole in ...
The circular import problem in Python. Some module foo imports module bar , but bar also imports foo . On itself, it's not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found