构建 pygdal 时出错:未知的分发选项:'use_2to3_fixers' 和 'use_2to3_exclude_fixers'



解决方案如下:

在Ubuntu 20.04上构建pygdal时开始出现错误:

# Command
python3 -m pip install --no-cache-dir pygdal==3.0.4.*

产生以下输出

Collecting pygdal==3.0.4.*
Downloading pygdal-3.0.4.6.tar.gz (458 kB)
|████████████████████████████████| 458 kB 3.7 MB/s 
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-we7e68ge/pygdal/setup.py'"'"'; __file__='"'"'/tmp/pip-install-we7e68ge/pygdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-we7e68ge/pygdal/pip-egg-info
cwd: /tmp/pip-install-we7e68ge/pygdal/
Complete output (5 lines):
/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_2to3_fixers'
warnings.warn(msg)
/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_2to3_exclude_fixers'
warnings.warn(msg)
error in pygdal setup command: use_2to3 is invalid.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

重现错误的步骤如下:

# Commands to run inside of running Ubuntu 20.04 docker instance
apt update
# install python3.8 and link python3 to this version - these next 2 steps may not be needed for your scenario
apt install -y python3.8
ln -s /usr/bin/python3.8 /usr/bin/python3
# done installing python3.8
apt install -y python3-pip
apt-get install -y python3-gdal gdal-bin libgdal-dev gcc g++ python3.8-dev git
python3 -m pip install --upgrade --no-cache-dir setuptools==58.0.4
python3 -m pip install --upgrade --no-cache-dir numpy wheel requests
python3 -m pip install --no-cache-dir pygdal==3.0.4.*

解决方案是安装旧版本的setuptools。指定58.0.2及更早版本会导致构建成功。对于这个问题,我只回到58.0.0,但这是我第一次看到这个问题,所以早期的版本应该也可以工作。

# Replace the above installation of setuptools with the following
python3 -m pip install --upgrade --no-cache-dir setuptools==58.0.2

用于安装GDAL 3.0.4版本。在我的情况下,我已经将setuptools从58.2.0版本降级到57.5.0版本。使用命令:

pip3 install setuptools==57.5.0

将上述安装的setuptools替换为以下

python3 -m pip install --upgrade --no-cache-dir setuptools==58.0.2

根据您使用的pygdal版本,您可能需要使用较早版本的setuptools

帮助我安装python GDAL版本,它与发行版GDAL相同。对于Ubuntu:

gadi@gadi:$ dpkg-query --list |grep gdal
ii  gdal-bin                                      3.4.1+dfsg-1build4                      amd64        Geospatial Data Abstraction Library 

pip install GDAL==3.4.1

最新更新