Python 安装osmnx时出错(必须指定GDAL API版本)问题

Python 安装osmnx时出错(必须指定GDAL API版本)问题,python,osmnx,Python,Osmnx,我想安装osmnx,我在cmd中编写了pip install osmnx,但它返回了一个错误: C:\Users\Horseman.mini>pip install osmnx Collecting osmnx Using cached https://files.pythonhosted.org/packages/69/77/98cbee7f94abe2c60013fd8751f2b2d6054d48078c61f9774cff0b341f43/osmnx-0.10-py2.py

我想安装osmnx,我在cmd中编写了
pip install osmnx
,但它返回了一个错误:

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.
我不能再在cmd中使用pip和python命令,所以我不能执行
pip安装osmnx
!如果我不设置所有这些,它将返回与开始时相同的错误

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

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版本。我还没做什么或做错了什么,也许这会有帮助

您必须安装和设置环境变量,在问题中提到的环境变量的基础上,您还必须添加一个
GDAL_版本
环境变量和您已经安装的版本,您可以通过从cmd运行
gdalinfo--VERSION
来检查它是哪一个,在我的例子中,环境变量的值将是
GDAL_VERSION=2.2.4
,它可能会根据安装的版本而变化

我不明白要成功安装osmnx应该做什么,应该指定什么以及如何指定


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

您必须设置GDAL环境变量:@FelipeGutierrez请查看我的编辑1您可以手动执行,如果它弄乱了事情,请在google上查找如何设置环境变量,%之间的第一件事是路径,下一件事是要设置的值。@FelipeGutierrez请参见编辑2。我返回了python和pip命令,但仍然不起作用。您介意运行我编写的批处理脚本吗?
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.