简体   繁体   English

GDAL安装->导入错误:DLL加载失败:找不到指定的程序

[英]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.以下是我在安装时遵循的各个步骤。

  1. Create a new environment创造新环境
conda create -n gdal_py37 python=3.7
  1. Activating the new environment激活新环境
conda activate gdal_py37
  1. Executing requirements file shown here .执行此处显示的需求文件。
pip install -r requirements.txt
  1. 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

  2. Implemented below line of code in python在 python 中的以下代码行中实现

import gdal
  1. Following is the error occurring以下是发生的错误
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:以下是您应该考虑的两件事:

  1. When using conda you don't want to use 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 文档 | 管理环境
  2. When working with geodata, datascience, etc. in conda, you really should use the 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.

相关问题 import pycurl ImportError:DLL加载失败:找不到指定的过程 - import pycurl ImportError: DLL load failed: The specified procedure could not be found Tensorflow 库导入错误:DLL 加载失败:找不到指定的程序 - Tensorflow library ImportError: DLL load failed: The specified procedure could not be found ImportError:DLL加载失败:找不到指定的过程。蟒蛇 - ImportError: DLL load failed: The specified procedure could not be found. Python import matplotlib ImportError:DLL加载失败:找不到指定的过程 - import matplotlib ImportError: DLL load failed: The specified procedure could not be found NumPy 库导入错误:DLL 加载失败:找不到指定的程序 - NumPy library ImportError: DLL load failed: The specified procedure could not be found lxml-ImportError:DLL加载失败:找不到指定的过程 - lxml - ImportError: DLL load failed: The specified procedure could not be found Tensorflow-GPU安装ImportError:DLL加载失败:找不到指定的模块 - Tensorflow-GPU Installation ImportError: DLL load failed: The specified module could not be found Windows Docker - Spacy language model installation in python returns ImportError: DLL load failed: The specified module could not be found - Windows Docker - Spacy language model installation in python returns ImportError: DLL load failed: The specified module could not be found DeepSpeech 安装错误:“ImportError:DLL 加载失败:找不到指定的模块。” - DeepSpeech Installation Error: "ImportError: DLL load failed: The specified module could not be found." from matplotlib import ft2font: “ImportError: DLL load failed: The specified procedure could not be found.” - from matplotlib import ft2font: “ImportError: DLL load failed: The specified procedure could not be found.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM