1 2 3 4 5 6 7 8 9 10 11
| apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
1. 下载源码包 wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz 2. mkdir -p /usr/local/python3 3. mv Python-3.7.3.tgz /usr/local/python3 4. tar -zxf Python-3.7.3.tgz 5. cd python3.7.3 6. ./configure --prefix=/usr/local/python3 --with-ssl --enable-optimizations 7. make 8. make install
|
1 2 3 4 5 6 7 8 9
| ln -s /usr/local/python3/bin/python3 /usr/bin/python3 [#确认是否是需要的版本] ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
# 这两个命令可做可不做 ln -s /usr/local/python3/bin/python3 /usr/bin/python [#确认是否是需要的版本] ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip
安装pip3 apt-get install python3-pip
|
yum报错解决
vim /usr/bin/yum
将yum文件内容中第一行的#!/usr/bin/python 改为:
!/usr/bin/python2.7
若yum update报错,需将 /usr/libexec/urlgrabber-ext-down 文件的第一行也改为:
#!/usr/bin/python2.7
mac 安装python
1 2
| brew install python brew install python@3.9 # 安装指定版本
|