Ubuntu上的ubuntu目前是旧版本,需要升级到3.10
注:非不得已不要用这种方式,用这个之后,导致python只从属于特定用户,导致其他用户无法调用/共用pip安装包,非常之麻烦
1.- 下载安装包
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz
2.-解压
tar -zxvf Python-3.10.10.tgz
cd Python-3.10.10/
3.- 编译安装
./configure --prefix=/usr/local
make
sudo make install
whereis python
4.- 切换版本
sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.10 300
sudo update-alternatives --config python
5.- 检查 (需要断开ssh连接再重新登陆)
上面的方法安装,由于将Python不是安装到默认目录,后续import module的时候会出一堆问题,后来使用如下方法重复安装一遍将python安装到默认路径。
cd Python-3.10.10/
./configure --enable-optimizations
sudo make altinstall (是altinstall 不是install,这样的话默认安装路径就是:/usr/bin/python)
如果不断提示包或模块缺失,可以从这个位置复制:/home/username/.local/lib/python3.10/site-packages/
其他:
Python3.10依赖包:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
Or:
sudo apt install build-essential software-properties-common libssl-dev libffi-dev python3-dev libgdbm-dev libc6-dev libbz2-dev libsqlite3-dev tk-dev libffi-dev zlib1g-dev
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
python --version
python3 --version
Debug module: sudo apt install python3.10-dbg
Developer (dev) module: sudo apt install python3.10-dev
VENV (virtual environment) module: sudo apt install python3.10-venv
Distutils module: sudo apt install python3.10-distutils
lib2to3 utility module: sudo apt install python3.10-lib2to3
DBM.GNU module: sudo apt install python3.10-gdbm
Tkinter module: sudo apt install python3.10-tk
包括以上所有:sudo apt install python3.10-full
pip
sudo apt install python3-pip
alias pip=pip3 (将pip和pip3并为一样的命令)
或者
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
sudo ln -s /usr/bin/pip3 /usr/bin/pip
或者
vim ~/.bashrc
alias pip="pip3"
source ~/.bashrc
pip --version
sudo pip3 install module-name (or: python3 -m pip install boto3)
pip安装包时,不要用sudo,不然会导致其它用户无法调用
python3 -m pip install --upgrade pip
pip --version
查boto3版本:pip3 show boto3
删除包:
pip uninstall xxx
删除旧版python:
sudo apt-get remove python2
sudo apt-get remove python3
卸载python3.8: sudo apt-get remove python3.8
卸载python3.8及其依赖: sudo apt-get remove --auto-remove python
清除python3.8: sudo apt-get purge python3.8 or sudo apt-get purge --auto-remove python3.8
其他步骤:
sudo apt-get remove python3.8
sudo apt-get autoremove
sudo apt-get autoclean