1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

centos6下同时安装python2和python3

2023-02-24 | centos | 1818ip | 6431°c
A+ A-
#build-essential compile packages
yum groupinstall "Development Tools"

yum install openssl-devel
yum install zlib-devel
yum install make gcc gcc-c++ kernel-devel

http://unix.stackexchange.com/questions/291737/zipimport-zipimporterror-cant-decompress-data-zlib-not-available

安装

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
cd Python-3.*
sudo ./configure
sudo make
sudo make install

注意make install完成后不应该出现Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS之类提示,出现Successfully installed pip-xxx才正确。

默认安装路径是/usr/local,可以通过prefix选项自定义,比如./configure --prefix=/opt/python3

http://***.com/questions/8087184/problems-installing-python3-on-rhel

软链接和alias

$ sudo ln -s /usr/local/bin/python3 /usr/bin/python3
$ alias python=/usr/bin/python3

一般python3目录下已经装好pip3了,如果没有,手动安装pip

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py 
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 8.7kB/s 
Collecting wheel
  Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, wheel
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
      Successfully uninstalled pip-8.1.1
Successfully installed pip-9.0.1 wheel-0.29.0

$ ln -s /usr/local/bin/pip3 pip3
$ alias pip=/usr/bin/pip3
$ pip --version
pip 9.0.1 from /usr/local/lib/python3.5/site-packages (python 3.5)

pyenv

提供更方便的多版本python管理:http://einverne.github.io/post/2017/04/pyenv.html

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32501.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。