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.

Error while importing Geopandas

See original GitHub issue

I have installed geopandas using !pip install geopandas. Before installing geopandas I installed gdal and fiona using the same method. But while importing geopandas, following error appears always. How do I rectify it ?

AttributeError                            Traceback (most recent call last)
<ipython-input-1-fc7d1d298f0c> in <module>
----> 1 import geopandas

~\anaconda3\lib\site-packages\geopandas\__init__.py in <module>
      5 from geopandas.array import points_from_xy  # noqa
      6 
----> 7 from geopandas.io.file import _read_file as read_file  # noqa
      8 from geopandas.io.arrow import _read_parquet as read_parquet  # noqa
      9 from geopandas.io.arrow import _read_feather as read_feather  # noqa

~\anaconda3\lib\site-packages\geopandas\io\file.py in <module>
     18 
     19 try:
---> 20     from fiona import Env as fiona_env
     21 except ImportError:
     22     try:

~\anaconda3\lib\site-packages\fiona\__init__.py in <module>
     86 
     87 import fiona._loading
---> 88 with fiona._loading.add_gdal_dll_directories():
     89     from fiona.collection import BytesCollection, Collection
     90     from fiona.drvsupport import supported_drivers

AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jorisvandenbosschecommented, Sep 25, 2021

OK, I can reproduce this by using the environment.yml file from movingpandas, and recreating that environment locally.

But, it seems this is actually an issue with the fiona install, because importing it on itself gives the following error (at least this is the issue for me locally, not 100% sure it’s the same issue on CI):

>>> import fiona
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/joris/miniconda3/envs/movingpandas/lib/python3.7/site-packages/fiona/__init__.py", line 86, in <module>
    from fiona.collection import BytesCollection, Collection
  File "/home/joris/miniconda3/envs/movingpandas/lib/python3.7/site-packages/fiona/collection.py", line 11, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: libdeflate.so.0: cannot open shared object file: No such file or directory
>>> import geopandas

But, so we are masking this import error message at the moment, and letting geopandas’ import fail because of fiona’s import error (which we don’t want to do, since it’s an optional dependency now).

It seems that https://github.com/geopandas/geopandas/pull/2112 might fix this specific issue (in case that fiona’s install is actually broken)

0reactions
anitagrasercommented, Oct 3, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in importing geopandas - python - Stack Overflow
The problem is caused by incompatibility of the fiona's and gdal's dependencies. Uninstall geopandas via conda. It will uninstall fiona as ...
Read more >
Error when importing geopandas · Issue #1756 - GitHub
After successfully installing geopandas, when I import it within jupyter notebooks [Having the most recent python and conda updates) the ...
Read more >
Error importing GeoPandas - python - GIS Stack Exchange
Error importing GeoPandas · Just install your required packages at the same time you install geopandas and let conda figure it out, i.e...
Read more >
Geopandas - Peter J Wilcoxen - InsightWorks
To make sure everything worked, start spyder and enter "import geopandas" in the console window. If all has gone well, it should quietly...
Read more >
Fastest way to install Geopandas in jupyter notebook on ...
First of all, if you will import geopandas without installing it, it will show this error which means we need to install it...
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