Ubuntu 18 安装 python 3.6
sudo add-apt-repository ppa:jonathonf/python-3.6
Ubuntu 18 安装 python3.7.0
因为安装的anaconda需要与python版本相对应,故安装的3.7.0版本。
安装过程参考:
https://blog.csdn.net/jaket5219999/article/details/80894517
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz && \ tar -xvf Python-3.7.1.tar.xz && cd Python-3.7.1 && ./configure && make && sudo make altinstall
从官网下载https://www.python.org/downloads/release/python-370/
解压并打开指定目录
./configure && make && sudo make altinstall
报错 zipimport.ZipImportError: can‘t decompress data; zlib not available
解决方法:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
python2,python3版本切换
# 实现 python 链接 python3.6 rm /usr/bin/python ln -s /usr/bin/python3.6 /usr/bin/python # 实现 python2 链接 Python2.7 rm /usr/bin/python2 ln -s /usr/bin/python2.7 /usr/bin/python2 # 创建 alias alias python=‘/usr/bin/python3.6‘ ~/.bash_aliases
pip安装
sudo apt-get install python3-pip
这里要用python3,否则匹配的是默认的python2。
原文地址:https://www.cnblogs.com/shiyublog/p/10011803.html
时间: 2024-10-04 15:37:15