簡體   English   中英

無法在 macos Sierra 的 python 3.6.1 中安裝 gdal

[英]Unable to install gdal in python 3.6.1 in macos Sierra

我試圖在 python 3.6.1 中安裝 gdal,但出現以下錯誤。 如何克服這一點?

bibinwilson ~ $ pip3 install gdal
 Collecting gdal Downloading GDAL-2.2.1.tar.gz (475kB) 100% |████████████████████████████████| 481kB 397kB/s Complete output from command python setup.py egg_info: running egg_info creating pip-egg-info/GDAL.egg-info writing pip-egg-info/GDAL.egg-info/PKG-INFO writing dependency_links to pip-egg-info/GDAL.egg-info/dependency_links.txt writing top-level names to pip-egg-info/GDAL.egg-info/top_level.txt writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt' warning: manifest_maker: standard file '-c' not found Traceback (most recent call last): File "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 131, in fetch_config p = subprocess.Popen([command, args], stdout=subprocess.PIPE) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__ restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child raise child_exception_type(errno_num, err_msg) 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 "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 179, in get_gdal_config return fetch_config(option, gdal_config = self.gdal_config) File "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 135, 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 "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 131, in fetch_config p = subprocess.Popen([command, args], stdout=subprocess.PIPE) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in __init__ restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child raise child_exception_type(errno_num, err_msg) 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 "<string>", line 1, in <module> File "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 339, in <module> **extra ) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup dist.run_commands() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands self.run_command(cmd) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 279, in run self.find_sources() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 306, in find_sources mm.run() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 533, in run self.add_defaults() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/egg_info.py", line 562, in add_defaults sdist.add_defaults(self) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/py36compat.py", line 36, in add_defaults self._add_defaults_ext() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/command/py36compat.py", line 119, in _add_defaults_ext build_ext = self.get_finalized_command('build_ext') File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/cmd.py", line 299, in get_finalized_command cmd_obj.ensure_finalized() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/cmd.py", line 107, in ensure_finalized self.finalize_options() File "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 214, in finalize_options self.gdaldir = self.get_gdal_config('prefix') File "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 188, in get_gdal_config return fetch_config(option) File "/private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/setup.py", line 135, in fetch_config raise gdal_config_error(e) __main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/43/7yqv__4j5776m508kggs_dxm0000gn/T/pip-build-naebgem9/gdal/

我遇到了這個錯誤,通過Homebrew安裝 GDAL 為我解決了這個問題。 為 GDAL 安裝二進制文件並沒有糾正錯誤,但是一旦我通過 brew 安裝它就解決了。

brew install gdal

似乎與此處的問題相同: Python GDAL: pip install --no-install GDAL failed

如果你已經安裝了二進制文件(就像我一樣)那么這個答案對我有用https : //stackoverflow.com/a/44051123/3969685

這個簡單的程序在 MAC sierra、python 3.6、GDAL 2.2.3 上似乎對我有用

1) 使用 dmg installer for MAC [GDAL MAC Frameworks] 安裝 GDAL 框架: http : //www.kyngchaos.com/software/frameworks

2)將 gdal-config 文件夾添加到您的路徑並獲取您的版本:

$ export PATH=/Library/Frameworks/GDAL.framework/Versions/2.2/Programs:$PATH

$ gdal-config --version

3)使用pip安裝gdal-config --version報告的gdal-config --version

$ pip install gdal==2.2.3

第 1 步似乎在其安裝框架文件夾下設置了 python 站點包,我認為您可以將它們復制到您的 python 站點包。 但最好使用 pip install。

這個簡單的程序似乎在 MAC 上對我有用

  1. 使用 Brew > brew install gdal 安裝 GDAL 框架
  2. gdal-配置--版本

gdal-配置--版本

2.4.4 3. GDAL Python 綁定 pip3 install gdal==2.4.4

注意命令末尾的 GDAL 版本,它必須與上一步使用 gdal-config 獲得的相同。 為避免沖突或任何其他問題,安裝和使用任何組件所需的確切版本非常重要。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM