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

时间:2019-11-26 15:32:49

标签: 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.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,应该指定什么以及如何指定? (当我尝试安装geopandas时,必须指定相同的GDAL API版本问题)。非常感谢您的帮助!

编辑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!如果我不设置所有这些内容,它将返回与开始时相同的错误。

编辑2: 我在python安装程序中使用过修复,它以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版本。我尚未完成或做错了什么? I found some info,也许会有所帮助

2 个答案:

答案 0 :(得分:2)

您必须为GDAL安装和设置环境变量,除了在问题中提到的那些变量之外,还必须添加一个GDAL_VERSION环境变量及其已安装的版本,您可以通过从cmd运行gdalinfo --version来检查它是哪一个。在我的情况下,环境变量的值为GDAL_VERSION=2.2.4,它可能会根据安装的版本而变化。

答案 1 :(得分:0)

<块引用>

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

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