python rasterio库和gdal库匹配与冲突问题安装办法
Posted 空中旋转篮球
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python rasterio库和gdal库匹配与冲突问题安装办法相关的知识,希望对你有一定的参考价值。
前言
近期在对栅格数据进行处理的过程中需要用到rasterio库,在使用pycharm安装的过程中出现了各种问题,pycharm无法安装成功。切换了各种网络环境(包括使用代理)都无法解决。后来还是使用直接下载库文件的方法进行安装。基本方法和之前安装gdal库方法相同(原文链接:python中如何导入gdal包?_空中旋转篮球的博客-CSDN博客_gdal包),但是出现了新得问题,存在gdal和rasterio版本匹配与兼容问题。
即安装的rasterio版本需要匹配对应的gdal版本,两者如果不兼容,则后安装的那个无法安装成功。
原始库文件下载地址如下:
GDAL库下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pip
raterio库下载地址: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pip
安装问题描述
我原始安装的gdal版本是:GDAL-3.2.3-cp37-cp37m-win_amd64.whl包。
下载的rasterio版本是:rasterio-1.2.10-cp37-cp37m-win_amd64.whl
将下载的包放置在自己项目路径D:\\pythonProject1\\venv\\Scripts 下面:
Ctrl+R打开命令提示符:
定位到自己的路径下,一次输入D: , cd D:\\pythonProject1\\venv\\Scripts
然后输入:pip install rasterio-1.2.10-cp37-cp37m-win_amd64.whl
出现以下问题:
D:\\pythonProject1\\venv\\Scripts>pip install GDAL-3.2.3-cp37-cp37m-win_amd64.whl
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Processing d:\\pythonproject1\\venv\\scripts\\gdal-3.2.3-cp37-cp37m-win_amd64.whl
GDAL is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
D:\\pythonProject1\\venv\\Scripts>pip install rasterio-1.2.10-cp37-cp37m-win_amd64.whl
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Processing d:\\pythonproject1\\venv\\scripts\\rasterio-1.2.10-cp37-cp37m-win_amd64.whl
Requirement already satisfied: setuptools in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (65.5.0)
Requirement already satisfied: click>=4.0 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (8.0.3)
Requirement already satisfied: numpy in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.21.5)
Requirement already satisfied: snuggs>=1.4.1 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.4.7)
Requirement already satisfied: click-plugins in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.1.1)
Requirement already satisfied: cligj>=0.5 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (0.7.2)
Collecting gdal~=3.4.1
Using cached GDAL-3.4.3.tar.gz (757 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: certifi in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (2021.10.8)
Requirement already satisfied: affine in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (2.3.1)
Requirement already satisfied: attrs in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (22.1.0)
Requirement already satisfied: colorama in d:\\pythonproject1\\venv\\lib\\site-packages (from click>=4.0->rasterio==1.2.10) (0.4.4)
Requirement already satisfied: importlib-metadata in d:\\pythonproject1\\venv\\lib\\site-packages (from click>=4.0->rasterio==1.2.10) (4.11.1)
Requirement already satisfied: pyparsing>=2.1.6 in d:\\pythonproject1\\venv\\lib\\site-packages (from snuggs>=1.4.1->rasterio==1.2.10) (3.0.6)
Requirement already satisfied: typing-extensions>=3.6.4 in d:\\pythonproject1\\venv\\lib\\site-packages (from importlib-metadata->click>=4.0->rasterio==1.2.10) (4.1.1)
Requirement already satisfied: zipp>=0.5 in d:\\pythonproject1\\venv\\lib\\site-packages (from importlib-metadata->click>=4.0->rasterio==1.2.10) (3.7.0)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Installing collected packages: gdal, rasterio
Attempting uninstall: gdal
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Found existing installation: GDAL 3.2.3
Uninstalling GDAL-3.2.3:
Successfully uninstalled GDAL-3.2.3
DEPRECATION: gdal is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for gdal ... error
error: subprocess-exited-with-error
× Running setup.py install for gdal did not run successfully.
│ exit code: 1
╰─> [120 lines of output]
running install
d:\\pythonproject1\\venv\\lib\\site-packages\\setuptools\\command\\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
running build
running build_py
creating build
creating build\\lib.win-amd64-cpython-37
creating build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\gdal.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\gdalconst.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\gdalnumeric.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\gdal_array.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\gnm.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\ogr.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\osr.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\utils.py -> build\\lib.win-amd64-cpython-37\\osgeo
copying osgeo\\__init__.py -> build\\lib.win-amd64-cpython-37\\osgeo
creating build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal2tiles.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal2xyz.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdalattachpct.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdalcompare.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdalmove.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_calc.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_edit.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_fillnodata.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_merge.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_pansharpen.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_polygonize.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_proximity.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_retile.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\gdal_sieve.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\ogrmerge.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\pct2rgb.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\rgb2pct.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
copying gdal-utils\\osgeo_utils\\__init__.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils
creating build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\array_util.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\base.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\batch_creator.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\color_palette.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\color_table.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\extent_util.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\gdal_argparse.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\numpy_util.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\osr_util.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\progress.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\raster_creation.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\rectangle.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\util.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
copying gdal-utils\\osgeo_utils\\auxiliary\\__init__.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\auxiliary
creating build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\assemblepoly.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\build_jp2_from_xml.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\classify.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\crs2crs2grid.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\densify.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\dump_jp2.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\epsg_tr.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\esri2wkt.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\fft.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\fix_gpkg.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gcps2ogr.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gcps2vec.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gcps2wld.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal2grd.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdalchksum.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdalcopyproj.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdalfilter.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdalident.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdalimport.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdalinfo.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdallocationinfo.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_auth.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_cp.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_create_pdf.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_ls.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_lut.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_mkdir.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_remove_towgs84.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_rm.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_rmdir.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_vrtmerge.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\gdal_zip.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\get_soundg.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\histrep.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\hsv_merge.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\jpeg_in_tiff_extract.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\load2odbc.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\loslas2ntv2.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\magphase.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\make_fuzzer_friendly_archive.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\mkgraticule.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogr2ogr.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogr2vrt.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogrinfo.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogrupdate.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogr_build_junction_table.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogr_dispatch.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\ogr_layer_algebra.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\rel.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\tigerpoly.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\tile_extent_from_raster.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\tolatlong.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\validate_cloud_optimized_geotiff.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\validate_gpkg.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\validate_jp2.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\val_repl.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\vec_tr.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\vec_tr_spat.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\wcs_virtds_params.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
copying gdal-utils\\osgeo_utils\\samples\\__init__.py -> build\\lib.win-amd64-cpython-37\\osgeo_utils\\samples
running build_ext
building 'osgeo._gdal' extension
building 'osgeo._gdalconst' extension
building 'osgeo._osr' extension
building 'osgeo._gdal_array' extension
building 'osgeo._ogr' extension
building 'osgeo._gnm' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
Rolling back uninstall of GDAL
Moving to d:\\pythonproject1\\venv\\lib\\site-packages\\gdal-3.2.3.dist-info\\
from d:\\pythonproject1\\venv\\lib\\site-packages\\~dal-3.2.3.dist-info
Moving to d:\\pythonproject1\\venv\\lib\\site-packages\\osgeo\\
from d:\\pythonproject1\\venv\\lib\\site-packages\\~sgeo
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\epsg_tr.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\epsg_tr.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\esri2wkt.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\esri2wkt.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gcps2vec.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gcps2vec.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gcps2wld.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gcps2wld.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal2tiles.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal2tiles.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal2xyz.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal2xyz.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_auth.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_auth.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_calc.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_calc.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_edit.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_edit.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_fillnodata.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_fillnodata.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_merge.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_merge.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_pansharpen.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_pansharpen.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_polygonize.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_polygonize.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_proximity.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_proximity.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_retile.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_retile.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdal_sieve.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdal_sieve.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdalchksum.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdalchksum.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdalcompare.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdalcompare.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdalident.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdalident.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdalimport.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdalimport.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\gdalmove.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\gdalmove.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\mkgraticule.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\mkgraticule.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\ogrmerge.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\ogrmerge.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\pct2rgb.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\pct2rgb.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\__pycache__\\rgb2pct.cpython-37.pyc
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-fzmup122\\rgb2pct.cpython-37.pyc
Moving to d:\\pythonproject1\\venv\\scripts\\epsg_tr.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\epsg_tr.py
Moving to d:\\pythonproject1\\venv\\scripts\\esri2wkt.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\esri2wkt.py
Moving to d:\\pythonproject1\\venv\\scripts\\gcps2vec.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gcps2vec.py
Moving to d:\\pythonproject1\\venv\\scripts\\gcps2wld.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gcps2wld.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal2tiles.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal2tiles.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal2xyz.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal2xyz.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_auth.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_auth.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_calc.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_calc.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_edit.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_edit.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_fillnodata.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_fillnodata.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_merge.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_merge.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_pansharpen.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_pansharpen.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_polygonize.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_polygonize.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_proximity.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_proximity.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_retile.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_retile.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdal_sieve.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdal_sieve.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdalchksum.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdalchksum.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdalcompare.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdalcompare.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdalident.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdalident.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdalimport.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdalimport.py
Moving to d:\\pythonproject1\\venv\\scripts\\gdalmove.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\gdalmove.py
Moving to d:\\pythonproject1\\venv\\scripts\\mkgraticule.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\mkgraticule.py
Moving to d:\\pythonproject1\\venv\\scripts\\ogrmerge.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\ogrmerge.py
Moving to d:\\pythonproject1\\venv\\scripts\\pct2rgb.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\pct2rgb.py
Moving to d:\\pythonproject1\\venv\\scripts\\rgb2pct.py
from C:\\Users\\RS001\\AppData\\Local\\Temp\\pip-uninstall-wif9wc9f\\rgb2pct.py
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> gdal
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
问题细节描述
长长的一串提示,到底进行了一些什么操作?我们将过程可以总结为以下几点:
第一个是开始检查安装环境,自动寻找和匹配gdal版本,提示需要3.4.1版本,可是我们可以上面的下载链接里面没有这个版本的库。
Processing d:\\pythonproject1\\venv\\scripts\\rasterio-1.2.10-cp37-cp37m-win_amd64.whl
Requirement already satisfied: setuptools in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (65.5.0)
Requirement already satisfied: click>=4.0 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (8.0.3)
Requirement already satisfied: numpy in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.21.5)
Requirement already satisfied: snuggs>=1.4.1 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.4.7)
Requirement already satisfied: click-plugins in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.1.1)
Requirement already satisfied: cligj>=0.5 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (0.7.2)
Collecting gdal~=3.4.1
接下来开始下载gdal 3.4.1库,并检查其他安装所需条件。
第二步,检查完成之后,检查到已经安装过3.2.3版本的gdal,于是先卸载这个库:
Installing collected packages: gdal, rasterio
Attempting uninstall: gdal
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Found existing installation: GDAL 3.2.3
Uninstalling GDAL-3.2.3:
Successfully uninstalled GDAL-3.2.3
第三步,卸载完成之后开始重新安装gdal
Running setup.py install for gdal ... error
error: subprocess-exited-with-error
× Running setup.py install for gdal did not run successfully.
│ exit code: 1
╰─> [120 lines of output]
running install
d:\\pythonproject1\\venv\\lib\\site-packages\\setuptools\\command\\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
running build
running build_py
creating build
第四步,新的gdal安装失败之后,又进行回滚操作,重新回滚到了3.2.3版本。
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
Rolling back uninstall of GDAL
Moving to d:\\pythonproject1\\venv\\lib\\site-packages\\gdal-3.2.3.dist-info\\
解决办法
下载gdal3.4.2版本,重新安装该版本gdal
输入:pip install GDAL-3.4.2-cp37-cp37m-win_amd64.whl
有很多报警提示,不过目前都能够正常使用,直接覆盖了之前的版本
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Processing d:\\pythonproject1\\venv\\scripts\\gdal-3.4.2-cp37-cp37m-win_amd64.whl
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Installing collected packages: GDAL
Attempting uninstall: GDAL
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Found existing installation: GDAL 3.2.3
Uninstalling GDAL-3.2.3:
Successfully uninstalled GDAL-3.2.3
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Successfully installed GDAL-3.4.2
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
重新安装rasterio
输入:pip install rasterio-1.2.10-cp37-cp37m-win_amd64.whl
D:\\pythonProject1\\venv\\Scripts>pip install rasterio-1.2.10-cp37-cp37m-win_amd64.whl
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Processing d:\\pythonproject1\\venv\\scripts\\rasterio-1.2.10-cp37-cp37m-win_amd64.whl
Requirement already satisfied: certifi in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (2021.10.8)
Requirement already satisfied: affine in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (2.3.1)
Requirement already satisfied: click-plugins in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.1.1)
Requirement already satisfied: setuptools in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (65.5.0)
Requirement already satisfied: gdal~=3.4.1 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (3.4.2)
Requirement already satisfied: snuggs>=1.4.1 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.4.7)
Requirement already satisfied: numpy in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (1.21.5)
Requirement already satisfied: click>=4.0 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (8.0.3)
Requirement already satisfied: attrs in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (22.1.0)
Requirement already satisfied: cligj>=0.5 in d:\\pythonproject1\\venv\\lib\\site-packages (from rasterio==1.2.10) (0.7.2)
Requirement already satisfied: colorama in d:\\pythonproject1\\venv\\lib\\site-packages (from click>=4.0->rasterio==1.2.10) (0.4.4)
Requirement already satisfied: importlib-metadata in d:\\pythonproject1\\venv\\lib\\site-packages (from click>=4.0->rasterio==1.2.10) (4.11.1)
Requirement already satisfied: pyparsing>=2.1.6 in d:\\pythonproject1\\venv\\lib\\site-packages (from snuggs>=1.4.1->rasterio==1.2.10) (3.0.6)
Requirement already satisfied: zipp>=0.5 in d:\\pythonproject1\\venv\\lib\\site-packages (from importlib-metadata->click>=4.0->rasterio==1.2.10) (3.7.0)
Requirement already satisfied: typing-extensions>=3.6.4 in d:\\pythonproject1\\venv\\lib\\site-packages (from importlib-metadata->click>=4.0->rasterio==1.2.10) (4.1.1)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Installing collected packages: rasterio
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
Successfully installed rasterio-1.2.10
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\\pythonproject1\\venv\\lib\\site-packages)
这样,rasterio就安装成功了。
其他提示
之前使用pip老是提示pip升级,于是使用 pip install -U pip 升级以下pip。
以上是关于python rasterio库和gdal库匹配与冲突问题安装办法的主要内容,如果未能解决你的问题,请参考以下文章