GDAL库安装报错
安装命令:
pip install GDAL
报错内容:
Collecting GDAL
Using cached gdal-3.9.1.tar.gz (840 kB)
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 2
╰─> [61 lines of output]
Ignoring oldest-supported-numpy: markers 'python_version == "3.8"' don't match your environment
Collecting setuptools>=67.0.0
Downloading setuptools-70.2.0-py3-none-any.whl.metadata (5.8 kB)
Collecting wheel
Downloading wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
Collecting numpy>=2.0.0rc1
Using cached numpy-2.0.0-cp39-cp39-win_amd64.whl.metadata (60 kB)
Downloading setuptools-70.2.0-py3-none-any.whl (930 kB)
0.0/930.8 kB ? eta -:--:--
ERROR: Exception:
Traceback (most recent call last):
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\urllib3\response.py", line 561, in read
data = self._fp_read(amt) if not fp_closed else b""
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\urllib3\response.py", line 527, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 98, in read
data: bytes = self.__fp.read(amt)
File "D:\anaconda3\envs\hsi_env\lib\http\client.py", line 463, in read
n = self.readinto(b)
File "D:\anaconda3\envs\hsi_env\lib\http\client.py", line 507, in readinto
n = self.fp.readinto(b)
File "D:\anaconda3\envs\hsi_env\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "D:\anaconda3\envs\hsi_env\lib\ssl.py", line 1275, in recv_into
return self.read(nbytes, buffer)
File "D:\anaconda3\envs\hsi_env\lib\ssl.py", line 1133, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapper
return func(self, options, args)
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\commands\install.py", line 377, in run
requirement_set = resolver.resolve(
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 179, in resolve
self.factory.preparer.prepare_linked_requirements_more(reqs)
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\operations\prepare.py", line 552, in prepare_linked_requirements_more
self._complete_partial_requirements(
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\operations\prepare.py", line 467, in _complete_partial_requirements
for link, (filepath, _) in batch_download:
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\network\download.py", line 183, in __call__
for chunk in chunks:
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\cli\progress_bars.py", line 53, in _rich_progress_bar
for chunk in iterable:
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_internal\network\utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\urllib3\response.py", line 622, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\urllib3\response.py", line 587, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "D:\anaconda3\envs\hsi_env\lib\contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "D:\anaconda3\envs\hsi_env\Lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 2
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
在GDAL官网添加链接描述看到支持conda安装,conda安装的说明页添加链接描述。
尝试了命令
conda install conda-forge/label/broken::gdal
仍然报错:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- conda-forge/label/broken::gdal -> python[version='>=2.7,<2.8.0a0|>=3.11,<3.12.0a0|>=3.12,<3.13.0a0|>=3.5,<3.6.0a0']
Your python: python=3.9
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
翻译一下就是我的python版本过高,不在代码给出的version选择范围里,于是换成了conda安装说明页里的另一个命令:
conda install conda-forge::gdal
这次成功了,安装说明页里列的几行命令复制如下:
conda install
To install this package run one of the following:
conda install conda-forge::gdal
conda install conda-forge/label/TEST::gdal
conda install conda-forge/label/broken::gdal
conda install conda-forge/label/cf201901::gdal
conda install conda-forge/label/cf202003::gdal
conda install conda-forge/label/gcc7::gdal