简体   繁体   English

无法在 Windows 上安装 Fiona

[英]Can't install Fiona on Windows

I've done a software on Ubuntu, and I'm having several problems running this software on Windows.我在 Ubuntu 上完成了一个软件,我在 Windows 上运行这个软件时遇到了几个问题。

My biggest issue point now is that I'm trying to install "fiona" - I have it already installed on my PIP packages - but for some reason it's not working.我现在最大的问题是我正在尝试安装“fiona”——我已经将它安装在我的 PIP 包上——但由于某种原因它无法正常工作。

So I've tried to install it via setup download from the original repository .所以我尝试通过从原始存储库下载安装程序来安装它。

By following the rules: using python setup.py install按照规则:使用 python setup.py install

I've already added some environment variables as:我已经添加了一些环境变量:

GDAL_DATA GDAL_DRIVER_PATH 

and beyond that I've added on variable PATH the path of GDAL除此之外,我在变量PATH中添加了GDAL的路径

There's another way to do it, by using another command but I don't how would it be还有另一种方法,通过使用另一个命令,但我不知道它会怎样

gdal include files

gdal library

python setup.py build_ext -I<path to gdal include files> -lgdal_i -L<path to gdal library> install --gdalversion 2.1

My current version of GDAL is GDAL 1.11.4, released 2016/01/25我当前的 GDAL 版本是 GDAL 1.11.4,发布于 2016/01/25

I'd already tried with 2.3 etc. and it didn't work.我已经尝试过 2.3 等,但它没有用。

I've tried using only this command:我试过只使用这个命令:

python setup.py install --gdalversion 1.11

fiona/_geometry.c(578) : fatal error C1083: Cannot open include file: 'ogr_api.h ': No such file or directory

Which results when I try to use a software that has fiona, I receive the following error:当我尝试使用具有 fiona 的软件时,我收到以下错误:

    import fiona
  File "C:\Python27\fiona\__init__.py", line 81, in <module>
    from fiona.collection import Collection, BytesCollection
  File "C:\Python27\fiona\collection.py", line 9, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: No module named ogrext

When building from source on Windows, it is important to know that setup.py cannot rely on gdal-config, which is only present on UNIX systems.在 Windows 上从源代码构建时,重要的是要知道 setup.py 不能依赖 gdal-config,它只存在于 UNIX 系统上。 On Windows, these paths need to be provided by the user.在 Windows 上,这些路径需要由用户提供。 You will need to find the include files and the library files for gdal and use setup.py您将需要找到 gdal 的包含文件和库文件并使用 setup.py

The GDAL DLL files and gdal-data directory need to be in your Windows PATH otherwise building Fiona will fail to work. GDAL DLL 文件和 gdal-data 目录需要在您的 Windows PATH 中,否则构建 Fiona 将无法工作。

Follow below steps to install Fiona and geopandas on windows按照以下步骤在 Windows 上安装 Fiona 和 geopandas

Step 1: Download the Fiona wheel from this website.第 1 步:网站下载 Fiona 车轮。 please pick the .whl package that correlates with your python interpreter as well system build (ie 32 bit or 64 bit)请选择与您的 python 解释器以及系统构建相关的 .whl 包(即 32 位或 64 位)

Step 2: Install fiona by using pip install path/to/fiona.whl第 2 步:使用pip install path/to/fiona.whl安装 fiona

Step 3: Install geopandas by using 'pip install geopandas'第 3 步:使用“pip install geopandas”安装 geopandas

To install Fiona on windows, you need to follow the below-mentioned steps: -要在 Windows 上安装 Fiona,您需要按照以下步骤操作:-

  1. You need to install GDAL wheel file using the link .您需要使用链接安装 GDAL 轮文件。 After visiting this link, download this file named GDAL‑3.0.4‑cp37‑cp37m‑win32.whl since it worked for me and then use the command访问此链接后,下载名为GDAL‑3.0.4‑cp37‑cp37m‑win32.whl因为它对我有用,然后使用命令
pip install c:\Users\........\GDAL‑3.0.4‑cp37‑cp37m‑win32.whl

to successfully install GDAL which is the requirement of Geopandas.成功安装 GDAL,这是 Geopandas 的要求。

  1. After installing the GDAL, you need to install a Fiona wheel file using the link .安装 GDAL 后,您需要使用链接安装 Fiona Wheel 文件。 Upon visiting this link, download the file named Fiona‑1.8.13‑cp37‑cp37m‑win32.whl since it is the supported wheel file for most of the windows users.访问此链接后,下载名为Fiona‑1.8.13‑cp37‑cp37m‑win32.whl文件,因为它是大多数 Windows 用户支持的 Wheel 文件。 After downloading this file, use the command下载此文件后,使用命令
pip install c:\Users\........\Fiona‑1.8.13‑cp37‑cp37m‑win32.whl

NOTE: If the above-mentioned wheel file doesn't work for you, then try using alternate wheel files.注意:如果上述轮文件不适合您,请尝试使用备用轮文件。

Finally after 6 hours of trying like crazy for installing Fiona.经过 6 个小时的疯狂尝试,终于安装了 Fiona。 I will try to make it as simple as possible.我会尽量让它变得简单。 Most of the guide are taken from here How to install GDAL大部分指南都取自这里How to install GDAL

Download the required gdal file here:在此处下载所需的 gdal 文件:

1) https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal 1) https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal

2) Then you can install the wheel file: 2)然后你可以安装轮文件:

python.exe -m pip install GDAL-2.2.4-cp35-cp35m-win_amd64.whl python.exe -m pip install GDAL-2.2.4-cp35-cp35m-win_amd64.whl

3) Add Environment Variable with the name GDAL_DATA and value = 3) 添加名为 GDAL_DATA 和 value = 的环境变量

C:\Users\yourUserName\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\osgeo\data\gdal C:\Users\yourUserName\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\osgeo\data\gdal

4) In most cases we require Visual C++ build tools. 4) 在大多数情况下,我们需要 Visual C++ 构建工具。 Install only the build tools and launch or download c++ visual studio from official link, Link to shortcut download from here:仅安装构建工具并从官方链接启动或下载 c++ Visual Studio,链接到此处的快捷方式下载:

Visual C++ 2015 Build Tools Visual C++ 2015 构建工具

5) Now install suitable fiona wheel from here here 5)现在从这里安装合适的菲奥娜轮

and run: pip install C:/path/to/Fiona‑1.8.4‑cp37‑cp37m‑win32.whl并运行: pip install C:/path/to/Fiona‑1.8.4‑cp37‑cp37m‑win32.whl

6) run pip install fiona 6) 运行 pip install fiona

You can use conda to install fiona.你可以使用 conda 来安装 fiona。 This is what I did:这就是我所做的:

  1. Make a virtual environment in Anaconda Navigator and install GDAL into this environement through the GUI.在 Anaconda Navigator 中创建一个虚拟环境,并通过 GUI 将 GDAL 安装到该环境中。
  2. Install shapely with pip install shapelypip install shapely
  3. install finona with conda install -c conda-forge fiona使用 conda conda install -c conda-forge fiona安装 finona

This worked for me.这对我有用。

I used conda-forge to install Fiona, but if this isn't an option for you, try using pipwin instead:我使用 conda-forge 安装 Fiona,但如果这不适合您,请尝试使用 pipwin:

pip install pipwin点安装 pipwin

pipwin install fiona pipwin 安装 fiona

I also used pipwin install geopandas and pipwin install gdal to get those libraries imported.我还使用 pipwin install geopandas 和 pipwin install gdal 来导入这些库。

The best way to deal with Fiona Package is using conda.处理 Fiona Package 的最佳方法是使用 conda。 I was facing same issue on Windows while was trying to install geopandas through:在尝试通过以下方式安装 geopandas 时,我在 Windows 上遇到了同样的问题:

pip3 install geopandas

So, to fix installation failure due to Fiona needing additional packages needed to compile I used:因此,为了修复由于 Fiona 需要编译所需的额外包而导致的安装失败,我使用了:

conda install geopandas

This worked for me in this exact order:这以这个确切的顺序对我有用:

pip install pipwin

pipwin install gdal

pipwin install fiona

pip install geopandas

Everything else did not work for me.其他一切都对我不起作用。 Using the wheels did not work because of "ERROR: GDAL‑3.4.3‑pp38‑pypy38_pp73‑win_amd64.whl is not a valid wheel filename.".由于“错误:GDAL‑3.4.3‑pp38‑py38_pp73‑win_amd64.whl 不是有效的轮子文件名。”,使用轮子不起作用。 Hope this helps someone.希望这可以帮助某人。

The best way is to use pipwin for installing gdal and then fiona.最好的方法是使用 pipwin 安装 gdal 然后 fiona。 Alternative option is to use pyogrio instead of fiona.另一种选择是使用 pyogrio 而不是 fiona。

You have to follow these steps:您必须按照以下步骤操作:

Step One: Download GDAL from here (You should choose the package that fits your architecture, amd64 for winx64 for example, and that fits your python version, cp39 for python3.9 for example)第一步:这里下载GDAL(你应该选择适合你架构的包,例如amd64 for winx64,并且适合你的python版本,例如cp39 for python3.9)

Step Two: Download Fiona from here第二步:这里下载 Fiona

Step Three: Install both with:第三步:安装两者:

pip install C:\Path\to\package.whl pip install C:\Path\to\package.whl

Step four: pip install geopandas第四步:点安装geopandas

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM