[英]GDAL Installation -> ImportError: DLL load failed: The specified procedure could not be found
I am trying to install 'GDAL' python package in conda.我正在尝试在 conda 中安装“GDAL”python package。 Following are the various steps I followed for the installation.以下是我在安装时遵循的各个步骤。
conda create -n gdal_py37 python=3.7
conda activate gdal_py37
pip install -r requirements.txt
From Anaconda Navigator-> environments-> 'gdal_py37' -> select gdal package from uninstalled packages -> Apply来自 Anaconda Navigator-> environments-> 'gdal_py37' -> select gdal package from uninstalled packages -> Apply
Implemented below line of code in python在 python 中的以下代码行中实现
import gdal
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_18824\1419450745.py in <module>
7 import os
8 import sys
----> 9 import gdal
10 import glob
11 from tqdm import tqdm
c:\Users\<<User>>\.conda\envs\gdal_py37\lib\site-packages\gdal.py in <module>
1 # import osgeo.gdal as a convenience
----> 2 from osgeo.gdal import deprecation_warn
3 deprecation_warn('gdal')
4
5 from osgeo.gdal import *
c:\Users\<<User>>\.conda\envs\gdal_py37\lib\site-packages\osgeo\__init__.py in <module>
19 fp.close()
20 return _mod
---> 21 _gdal = swig_import_helper()
22 del swig_import_helper
23 else:
c:\Users\<<User>>\.conda\envs\gdal_py37\lib\site-packages\osgeo\__init__.py in swig_import_helper()
15 if fp is not None:
...
--> 342 return _load(spec)
343
344 else:
ImportError: DLL load failed: The specified procedure could not be found.
How can I resolve this error?我该如何解决这个错误?
There is probably a compatibility issue with another package. This can easily happen when you are using conda with pip
.另一个 package 可能存在兼容性问题。当您将 conda 与pip
一起使用时,很容易发生这种情况。 Here are two things you should consider:以下是您应该考虑的两件事:
pip
because it often leads to package incompabilities as pointed out above.使用 conda 时,您不想使用pip
,因为如上所述,它通常会导致 package 不兼容。 Use the conda package manager together with environment.yml
files ( conda docs | managing environments )将 conda package 管理器与environment.yml
文件一起使用( conda 文档 | 管理环境)conda-forge
channel .在 conda 中处理地理数据、数据科学等时,您确实应该使用conda-forge
forge通道。 Add the conda-forge
channel by running通过运行添加conda-forge
通道
conda config --add channels conda-forge
conda config --set channel_priority strict
If you did not remove your non-functioning environment yet, do it with conda env remove -n gdal_py37
.如果您还没有删除无法运行的环境,请使用conda env remove -n gdal_py37
进行删除。
Create a file environment.yml
which replaces your requirements.txt
and should look like this:创建一个文件environment.yml
替换您的requirements.txt
并且应该如下所示:
name: gdal_py37
channels:
- conda-forge
dependencies:
- gdal=3.5.2
- python=3.7
Create your environment with its dependencies by running:通过运行以下命令创建具有依赖项的环境:
conda env create -f environment.yml
Activate your environment with conda activate gdal_py37
.使用conda activate gdal_py37
激活您的环境。
Now start python
and run the following:现在启动python
并运行以下命令:
from osgeo import gdal
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.