由于安装kitti2bag需要使用pip,出现了以下sys.stderr.write(f"ERROR: {exc}")问题
一、问题
使用pip出现以下问题:
astronaut@astronaut:~$ pip --version
Traceback (most recent call last):
File "/home/astronaut/.local/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/home/astronaut/.local/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}") ^
SyntaxError: invalid syntax
二、解决方法
1.原因:
我的ubuntu时1604,是pip的版本冲突导致的问题。
参考博客:https://blog.csdn.net/hardhard123/article/details/113251805
2.解决:
运行:
wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
与参考链接代码不同的原因是官方链接发生了改变:
astronaut@astronaut:~$ python3 get-pip.py
Hi there!
The URL you are using to fetch this script has changed, and this one will no
longer work. Please use get-pip.py from the following URL instead:
https://bootstrap.pypa.io/pip/3.5/get-pip.py
Sorry if this change causes any inconvenience for you!
We don't have a good mechanism to make more gradual changes here, and thisrenaming is a part of an effort to make it easier to us to update thesescripts, when there's a pip release. It's also essential for improving how we handle the `get-pip.py` scripts, when pip drops support for a Python minorversion.
There are no more renames/URL changes planned, and we don't expect that a need would arise to do this again in the near future.
Thanks for understanding!
- Pradyun, on behalf of the volunteers who maintain pip.
运行结果:
astronaut@astronaut:~$ wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
--2021-04-09 14:53:54-- https://bootstrap.pypa.io/pip/3.5/get-pip.py
正在解析主机 bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.228.175, 2a04:4e42:2e::175
正在连接 bootstrap.pypa.io (bootstrap.pypa.io)|151.101.228.175|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 1908223 (1.8M) [text/x-python]
正在保存至: “get-pip.py.4”
get-pip.py.4 100%[===================>] 1.82M 1.03MB/s in 1.8s
2021-04-09 14:53:57 (1.03 MB/s) - 已保存 “get-pip.py.4” [1908223/1908223])
一定一定要仔细看你生成的get-pip.py.4名称!!!有的之前生成过后缀不同。
再运行
python3 get-pip.py.4
结果:
astronaut@astronaut:~$ python3 get-pip.py.4
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pip<21.0
Using cached pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.4
如果 python3 get-pip.py.4的文件输错,会重复出现官方网址变化的问题。
安装kitti2bag
pip install kitti2bag
结束