安装osmnx时出错(A GDAL API version must be specified)问题

Error when installing osmnx (A GDAL API version must be specified) problem

我想安装 osmnx,我在 cmd 中写了 pip install osmnx,但是 returns 我出错了:

C:\Users\Horseman.mini>pip install osmnx
Collecting osmnx
Using cached     https://files.pythonhosted.org/packages/69/77/98cbee7f94abe2c60013fd8751f2b2d6054d48078c61f9774cff0b341f43/osmnx-0.10-py2.py3-none-any.whl
Requirement already satisfied: numpy>=1.16 in     c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from osmnx) (1.17.4)
Collecting networkx>=2.3
Using cached https://files.pythonhosted.org/packages/41/8f/dd6a8e85946def36e4f2c69c84219af0fa5e832b018c970e92f2ad337e45/networkx-2.4-py3-none-any.whl
Requirement already satisfied: Shapely>=1.6 in     c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from osmnx) (1.6.4.post2)
Requirement already satisfied: requests>=2.21 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from osmnx) (2.22.0)
Requirement already satisfied: pandas>=0.24 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from osmnx) (0.25.3)
Requirement already satisfied: matplotlib>=2.2 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from osmnx) (3.1.2)
Collecting Rtree>=0.8.3
Downloading https://files.pythonhosted.org/packages/36/2f/9dc53cfb8edb32a0fb89e689f89e3b4c1a4455652032386fd2dd034c711a/rtree-0.9.1-0_py37hbf79ddb-cp37-cp37m-win_amd64.whl (3.8MB)
 |████████████████████████████████| 3.8MB 595kB/s
Collecting descartes>=1.1
Using cached https://files.pythonhosted.org/packages/e5/b6/1ed2eb03989ae574584664985367ba70cd9cf8b32ee8cad0e8aaeac819f3/descartes-1.1.0-py3-none-any.whl
Collecting geopandas>=0.5
Using cached https://files.pythonhosted.org/packages/5b/0c/e6c99e561b03482220f00443f610ccf4dce9b50f4b1093d735f93c6fc8c6/geopandas-0.6.2-py2.py3-none-any.whl
Requirement already satisfied: decorator>=4.3.0 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from networkx>=2.3->osmnx) (4.4.1)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from requests>=2.21->osmnx) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from requests>=2.21->osmnx) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from requests>=2.21->osmnx) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from requests>=2.21->osmnx) (1.25.7)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from pandas>=0.24->osmnx) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from pandas>=0.24->osmnx) (2019.3)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from matplotlib>=2.2->osmnx) (2.4.5)
Requirement already satisfied: cycler>=0.10 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from matplotlib>=2.2->osmnx) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\horseman.mini\appdata\local\programs\python\python37\lib\site-packages (from matplotlib>=2.2->osmnx) (1.1.0)
Collecting fiona
Using cached https://files.pythonhosted.org/packages/9d/f4/0a0ddc6174c4a93679b5f1dd3535e7ef8989828e6d5f86112de681f8c87b/Fiona-1.8.11.tar.gz
 ERROR: Command errored out with exit status 1:
 command: 'c:\users\horseman.mini\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-ecd90yd9\fiona\setup.py'"'"'; __file__='"'"'C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-ecd90yd9\fiona\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-ecd90yd9\fiona\pip-egg-info'
     cwd: C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-ecd90yd9\fiona\
Complete output (1 lines):
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我使用 windows 10,python 版本:2.7 和 3.7

我不明白我应该怎么做才能成功安装 osmnx,我应该指定什么以及如何指定? (相同的 GDAL API 版本必须指定我在尝试安装 geopandas 时遇到的问题)。如果你能提供帮助,我将不胜感激!

编辑 1: 我可以在安装后自由导入 gdal,但是在我这样做之后:

setx PATH "%PATH%;C:\Program Files (x86)\GDAL"
setx PATH "%GDAL_DATA%;C:\Program Files (x86)\GDAL\gdal-data"
setx PATH "%GDAL_DRIVER_PATH%;C:\Program Files (x86)\GDAL\gdalplugins"

我不能再在 cmd 中使用 pip 和 python 命令,所以我不能 pip install osmnx!如果我不设置所有这些,它 returns 我会遇到与开始时相同的错误。

编辑 2: 我在 python 安装程序中使用了修复,它在 cmd 中返回了我的 pip 和 python 命令。安装 gdal 后导入良好,但在 pip install osmnx 之后 returns 我同样的错误

ERROR: Command errored out with exit status 1:
 command: 'c:\users\horseman.mini\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-iqd4diwx\fiona\setup.py'"'"'; __file__='"'"'C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-iqd4diwx\fiona\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-iqd4diwx\fiona\pip-egg-info'
     cwd: C:\Users\HORSEM~1.MIN\AppData\Local\Temp\pip-install-iqd4diwx\fiona\
Complete output (1 lines):
A GDAL API version must be specified. Provide a path to gdal-config using a 
GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

据我了解,我安装了 gdal,但尚未指定 gdal 版本。我还没有做或做错了什么? I found some info,也许会有帮助

您必须为安装和设置环境变量,在问题中提到的那些之上,您还必须添加一个GDAL_VERSION环境变量与您已经安装的版本,您可以通过 cmd 运行 gdalinfo --version 检查它是哪一个,在我的例子中,环境变量的值将是 GDAL_VERSION=2.2.4,它可能会根据您安装的版本而改变。

I don't understand what should I do to successfully install osmnx, what should I specify and how?

请注意,OSMnx 安装 instructions 提供简单的分步说明。您不必进行任何复杂的 GDAL 配置等。