fiona import issues in python

和自甴很熟 提交于 2021-02-19 04:51:26

问题


i have installed fiona using whl distributions.. but while importing i am getting following error :

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b0161244e1be> in <module>()
----> 1 import fiona
      2 with fiona.open(r'C:\Users\harish.padi\Downloads\BSP\BSP\BSP_default_pred.shp', 'r') as input:
      3     with open(r'C:\Users\harish.padi\Downloads\BSP\BSP\output.txt', 'w') as output:
      4        for pt in input:
      5            id = pt['properties']['id']

c:\program files\python36\lib\site-packages\fiona\__init__.py in <module>()
     75     pass
     76 
---> 77 from fiona.collection import Collection, BytesCollection, vsi_path
     78 from fiona._drivers import driver_count, GDALEnv
     79 from fiona.drvsupport import supported_drivers

c:\program files\python36\lib\site-packages\fiona\collection.py in <module>()
      7 
      8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
     10 from fiona.ogrext import Session, WritingSession
     11 from fiona.ogrext import (

ImportError: DLL load failed: The specified module could not be found.

can anyone suggest a solution.?


回答1:


I had also some troubles when i installed fiona and tried to import it. I had this kind of message

>>> import fiona
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Software\Ingenieria\Anaconda2\lib\site-packages\fiona\__init__.py", l
ine 77, in <module>
    from fiona.collection import Collection, BytesCollection, vsi_path
  File "D:\Software\Ingenieria\Anaconda2\lib\site-packages\fiona\collection.py",
 line 9, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: DLL load failed: The specified module could not be found.

How did it work for me at the end?

  • I installed the distributions GDAL 2.2.4 and Fiona from this link
  • Then i checked if my computer has a c++ compiler for python (here link with some information about which one you may need to install). In some forum questions i read that GDAL need this compiler to be able to work.
  • Then i added the Osgeo folder path (there are the dlls for fiona) to my path environment variable, some pics from my pc Print screen 1 Print screen 2

After doing those steps i never had any more problems with fiona. At first, i was using the GDAL version 1.1.4 but it never worked with this one. You can try first with the version one, and if it doesn´t work then install the version 2.2.4




回答2:


Maybe is better to mention that GDAL 2.2.4 is for Python 2.7 (as in the link provided).

I was having the same ImportError issue with Python 3.7, Fiona 1.8.6 and GDAL 3.0.0

By replacing GDAL 3.0.0 with 2.2.4 I got it working, without consideration of the other details




回答3:


You are missing DLLs for either OGR, GDAL, or both. Your post is scant on details such as operating system, etc so the best I can do is refer you to the installation instructions:

http://toblerity.org/fiona/README.html#installation

Also, I noticed you seem to be using Python 3.6. To quote the instructions:

"Fiona requires Python 2.6, 2.7, 3.3, or 3.4 and GDAL/OGR 1.8+."

That could be a potential issue as well.



来源:https://stackoverflow.com/questions/50836635/fiona-import-issues-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!