需要离线安装GDAL
(venv) [root@VM-8-12-centos ~]# pip install gdal
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting gdal
Downloading http://mirrors.tencentyun.com/pypi/packages/bd/10/85c41cc7c520be9cf755f5862e8c6c8b0c91c8987cb1c706f7092f9893ee/gdal-3.9.2.tar.gz (840 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 840.6/840.6 kB 3.2 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
Traceback (most recent call last):
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-mli7azgz/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "/tmp/pip-build-env-mli7azgz/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-mli7azgz/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 318, in run_setup
exec(code, locals())
File "<string>", line 202, in <module>
Exception: numpy not available! This error may happen if you build/install using setup.py directly, but should normally not happen if you install using pip install. If you still want to build the bindings without numpy support, define the GDAL_PYTHON_BINDINGS_WITHOUT_NUMPY environment variable
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
(venv) [root@VM-8-12-centos ~]#
(venv) [root@VM-8-12-centos ~]# pip install numpy
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Requirement already satisfied: numpy in ./MYPROJECT/backend/venv/lib/python3.8/site-packages (1.24.4)
============================================
(venv) [root@VM-8-12-centos ~]# pip install gdal==3.4.3
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting gdal==3.4.3
Using cached http://mirrors.tencentyun.com/pypi/packages/12/82/ed7f65fe6ab931514807c79370096a816ad8cad6cef03a2fef90845503f6/GDAL-3.4.3.tar.gz (757 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [140 lines of output]
running egg_info
creating /tmp/pip-pip-egg-info-84igj4c2/GDAL.egg-info
writing /tmp/pip-pip-egg-info-84igj4c2/GDAL.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-84igj4c2/GDAL.egg-info/dependency_links.txt
writing requirements to /tmp/pip-pip-egg-info-84igj4c2/GDAL.egg-info/requires.txt
writing top-level names to /tmp/pip-pip-egg-info-84igj4c2/GDAL.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-84igj4c2/GDAL.egg-info/SOURCES.txt'
/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/dist.py:478: SetuptoolsDeprecationWarning: Invalid dash-separated options
!!
********************************************************************************
Usage of dash-separated 'index-url' will not be supported in future
versions. Please use the underscore name 'index_url' instead.
By 2024-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
********************************************************************************
!!
opt = self.warn_dash_deprecation(opt, section)
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 105, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/usr/local/python3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/python3/lib/python3.8/subprocess.py", line 1720, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 188, in get_gdal_config
return fetch_config(option, gdal_config=self.gdal_config)
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 108, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 105, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/usr/local/python3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/python3/lib/python3.8/subprocess.py", line 1720, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 195, in get_gdal_config
return fetch_config(option)
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 108, in fetch_config
raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 389, in <module>
setup(**setup_kwargs)
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 103, in setup
return distutils.core.setup(**attrs)
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 184, in setup
return run_commands(dist)
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
dist.run_commands()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/dist.py", line 976, in run_command
super().run_command(command)
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 321, in run
self.find_sources()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 329, in find_sources
mm.run()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 550, in run
self.add_defaults()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 588, in add_defaults
sdist.add_defaults(self)
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/command/sdist.py", line 102, in add_defaults
super().add_defaults()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 250, in add_defaults
self._add_defaults_ext()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 334, in _add_defaults_ext
build_ext = self.get_finalized_command('build_ext')
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 303, in get_finalized_command
cmd_obj.ensure_finalized()
File "/root/MYPROJECT/backend/venv/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
self.finalize_options()
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 258, in finalize_options
self.gdaldir = self.get_gdal_config('prefix')
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 201, in get_gdal_config
raise gdal_config_error(traceback_string + '\n' + msg)
__main__.gdal_config_error: Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 105, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/usr/local/python3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/python3/lib/python3.8/subprocess.py", line 1720, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 188, in get_gdal_config
return fetch_config(option, gdal_config=self.gdal_config)
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 108, in fetch_config
raise gdal_config_error(e)
gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 105, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/usr/local/python3/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/python3/lib/python3.8/subprocess.py", line 1720, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 195, in get_gdal_config
return fetch_config(option)
File "/tmp/pip-install-146bu4z0/gdal_6d483f8c540042a9a0c237df0afd1a01/setup.py", line 108, in fetch_config
raise gdal_config_error(e)
gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
Could not find gdal-config. Make sure you have installed the GDAL native library and development headers.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(venv) [root@VM-8-12-centos ~]#
============================================
linux安装python的GDAL包时,总是出现如下错误:
gdal_config_error: [Errno 2] No such file or directory: ‘gdal-config’
Could not find gdal-config. Make sure you have installed the GDAL native library and development headers.
查了许多资料,都不行。
索性改变思路,去找linux下python的轮子,还真就找到了
linux下python的GDAL轮子链接如下:
https://sourceforge.net/projects/gdal-wheels-for-linux/files/
但是只有3.6、3.7版本的python轮子,因此需要重新下载3.6或者3.7版本的python,linux下安装python请参考其他博文。
下载好轮子之后,python -m pip install 轮子.wheel
链接:https://blog.csdn.net/qq_36181130/article/details/121519519
============================================
离线安装GDAL
https://sourceforge.net/projects/gdal-wheels-for-linux/files/
GDAL-3.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl 2022-02-03 76.0 MB
42
GDAL-3.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl 2022-02-03 76.0 MB
64
GDAL-3.4.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl 2022-02-03 76.1 MB
4
GDAL-3.4.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl 2022-02-03 76.1 MB
3
GDAL-3.1.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl 2021-05-13 70.3 MB
45
GDAL-3.1.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl 2021-05-13 70.3 MB
(venv) [root@VM-8-12-centos software]# pip install GDAL-3.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Processing ./GDAL-3.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Requirement already satisfied: numpy>=1.21.3 in /root/MYPROJECT/backend/venv/lib/python3.8/site-packages (from GDAL==3.4.1) (1.24.4)
Installing collected packages: GDAL
Successfully installed GDAL-3.4.1
(venv) [root@VM-8-12-centos software]#
============================================
标签:CentOS,安装,py,GDAL,File,pip,line,config,gdal From: https://www.cnblogs.com/emanlee/p/18389806