How to update to the latest Python version On Linux All In One
How to update to the latest Python version On Linux All In One
update to the latest Python version on
Raspberry Pi
errors
old
$ python --version
Python 3.9.2
new
$ sudo apt update
$ apt list | grep python3.10
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libqgispython3.10.14/oldstable 3.10.14+dfsg-1 arm64
libqgispython3.10.14/oldstable 3.10.14+dfsg-1 armhf
$ sudo apt install python3.10
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
E: 无法定位软件包 python3.10
E: 无法按照 glob ‘python3.10’ 找到任何软件包
$ apt list | grep python3.10.
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libqgispython3.10.14/oldstable 3.10.14+dfsg-1 arm64
libqgispython3.10.14/oldstable 3.10.14+dfsg-1 armhf
$ sudo apt install python3.10.14
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
E: 无法定位软件包 python3.10.14
E: 无法按照 glob ‘python3.10.14’ 找到任何软件包
$ python --version
solutions
- Download for macOS
Python 3.11.4
https://www.python.org/ftp/python/3.11.4/python-3.11.4-macos11.pkg
https://www.python.org/downloads/
PEP 619 – Python 3.10 Release Schedule
Release Created:25-May-2020
Python-Version: 3.10
https://peps.python.org/pep-0619/
- zsh
.zshrc
# > 覆盖写入配置文件
# >> 追加写入配置文件
$ echo "alias py=/usr/bin/python3" >> ~/.zshrc
$ echo "alias python=/usr/bin/python3" >> ~/.zshrc
How to use brew install the latest python3 on macOS
?
.pkg
https://www.python.org/ftp/python/3.11.4/python-3.11.4-macos11.pkg
cd '' && '/usr/local/bin/python3' '
' && echo Exit status: $? && exit 1`
➜ bin cd /usr/bin/ && ls | grep "python"
python3
➜ bin cd /usr/bin/ && ls | grep "python"
python3
➜ bin python --version
zsh: permission denied: /usr/local/lib/python3.11
➜ bin source ~/.zshrc
➜ bin python --version
Python 3.9.6
➜ bin which python
python: aliased to /usr/bin/python3
➜ bin /usr/local/bin/python3 --version
Python 3.11.4
➜ bin /usr/local/bin/python3 --version
Python 3.11.4
➜ bin /sw/bin/python3 --version
zsh: no such file or directory: /sw/bin/python3
➜ bin python --version
Python 3.9.6
➜ bin python3 --version
Python 3.9.6
➜ bin
.zshrc
# Python 3 ✅
# alias python=/usr/bin/python3
# alias py3='python3'
alias python=/usr/local/bin/python3
alias py3='python'
# which python3
# /usr/bin/python3
# which python
# python: aliased to /usr/local/bin/python3
# source ~/.zshrc ✅
# export PATH="/usr/bin/python3:$PATH"
# export PATH="/usr/bin/:$PATH"
# $ cd /usr/bin/ && ls | grep "python" ✅
# $ cd /usr/bin/ && ls -al | grep "python" ✅
# Python3.11
# alias python=/usr/local/lib/python3.11
# alias py3='python'
# export PATH="/usr/local/lib/python3.11:$PATH"
# source ~/.zshrc ✅
# /usr/local/bin/python3
# /opt/local/bin/python3
# /sw/bin/python3
# /usr/local/bin/python3 --version
# Python 3.11.4
# /usr/local/bin/python3 --version
# Python 3.11.4
# .bash_profile
source ~/.bash_profile
# end zsh
# source ~/.zshrc
Python 3.11.4
$ python --version
Python 3.11.4
$ py3
Python 3.11.4 (v3.11.4:d2340ef257, Jun 6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
- brew
python@3.y
/Python 3.y.z
# ❌
$ brew install python@3.11.4
# ✅ 不好使 ❓
$ brew install python@3.11
https://formulae.brew.sh/formula/python@3.11
https://formulae.brew.sh/formula/python@3.10
https://formulae.brew.sh/formula/python@3.9
https://docs.brew.sh/Homebrew-and-Python#python-3y
https://docs.python-guide.org/starting/install3/osx/
demos
Pyhton 3.10.x
switch...case
❌
match...case
✅
#!/usr/bin/env python3
# coding: utf8
__author__ = 'xgqfrms'
__editor__ = 'vscode'
__version__ = '1.0.1'
__github__ = 'https://github.com/xgqfrms/Raspberry-Pi'
__git__ = 'https://github.com/xgqfrms/Raspberry-Pi.git'
__copyright__ = """
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
"""
"""
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2020-01-01
* @updated 2023-07-01
*
* @description
* @augments
* @example
* @link
*
*/
"""
# Match statements require Python `3.10` or newer Pylance ❌
def http_error(status):
match status:
case 400:
return "Bad request"
case 404:
return "Not found"
case 418:
return "I'm a teapot"
case _:
return "Something's wrong with the internet"
def test():
status = 400
message = http_error(status)
print("message =", message)
test()
"""
$ py3 ./match...case.py
"""
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
refs
https://cloudbytes.dev/snippets/upgrade-python-to-latest-version-on-ubuntu-linux
https://hub.tcno.co/pi/software/python-update/
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17613043.html
未经授权禁止转载,违者必究!