English 中文(简体)
进口/进口:不能从中途进口
原标题:ImportError: cannot import name _gdal_array from osgeo
  • 时间:2023-02-07 10:46:58
  •  标签:
  • python
  • gdal

我创造新的环境,安装 n,然后安装GDAL。 GDAL进口成功,我可以通过<代码>gdal开放图像。 开放(,但我收到 ImportError:在试图使用时,不能从sgeo 上进口_gdal_array ReadAs Raster

<编码>pip> 回归:

GDAL       3.6.2
numpy      1.24.2
pip        23.0
setuptools 65.6.3
wheel      0.38.4

Completely stumped, has anyone come across this? Google tells me that installing numpy first is the solution (but that doesn t help). Help would be much appreciated.

最佳回答

尽管你安装了 n,但Pip最有可能 over和重塑贵的GDAL版本。 这里对我来说是固定的:

pip3 install --no-cache-dir --force-reinstall GDAL[numpy]==3.6.2

没有<代码>-无-cache-dir的批次 • causes

% pip3 install --force-reinstall  GDAL[numpy]==3.6.2 
Collecting GDAL[numpy]==3.6.2
  Using cached GDAL-3.6.2-cp311-cp311-macosx_13_0_x86_64.whl
Collecting numpy>1.0.0
  Using cached numpy-1.24.2-cp311-cp311-macosx_10_9_x86_64.whl (19.8 MB)
Installing collected packages: numpy, GDAL
  Attempting uninstall: numpy
    Found existing installation: numpy 1.24.2
    Uninstalling numpy-1.24.2:
      Successfully uninstalled numpy-1.24.2
  Attempting uninstall: GDAL
    Found existing installation: GDAL 3.6.2
    Uninstalling GDAL-3.6.2:
      Successfully uninstalled GDAL-3.6.2
Successfully installed GDAL-3.6.2 numpy-1.24.2

对于仍然遇到这一问题的其他人,确保安装<代码>wheel和setuptools。 Pip将考虑setuptools>=48,但这是错误的,因为你需要的是64个以上的新人。 与<代码>69.1.1一致

Pip将下载<代码>wheel <>/code>和/或setuptools,作为建筑过程的一部分,但(截至2024年3月)不会奏效,而是责备:

Building wheels for collected packages: GDAL
  Running command Building wheel for GDAL (pyproject.toml)
  WARNING: numpy not available!  Array support will not be enabled

唯一注明的是wheel setuptools 问题表明,在无建筑隔离的情况下建造房屋(-no-build-isolation):

  error: invalid command  bdist_wheel 
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
Preparing metadata (pyproject.toml) ... done
ERROR: Exception:
Traceback (most recent call last):
...
ModuleNotFoundError: No module named  setuptools 
问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签