我已经在Ubuntu 20.04 LTS中安装了Python 3.9。现在系统上有Python 3.8和Python 3.9两个版本。
# which python
# which python3
/usr/bin/python3
# which python3.8
/usr/bin/python3.8
# which python3.9
/usr/bin/python3.9
# ls -alith /usr/bin/python3
12583916 lrwxrwxrwx 1 root root 9 Jul 19 2021 /usr/bin/python3 -> python3.8
但是pip3
命令仍会将所有内容安装到Python 3.8目录中。
# pip3 install --upgrade --find-links file:///path/to/directory <...>
我想通过更新符号链接 /usr/bin/python3 到 /usr/bin/python3.9 来更改默认的 pip3 行为。
怎么做呢?
# update-alternatives --set python3 /usr/bin/python3.9
This command will not work as expected.
这里是pip3信息:
# which pip3
/usr/bin/pip3
# ls -alith /usr/bin/pip3
12589712 -rwxr-xr-x 1 root root 367 Jul 13 2021 /usr/bin/pip3
# pip3 -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
#
alias
命令将不起作用:
# alias python3=python3.9
# ls -alith /usr/bin/python3
12583916 lrwxrwxrwx 1 root root 9 Jul 19 2021 /usr/bin/python3 -> python3.8
python -m pip install ...
- Adid