linux下安装python环境 £神魔★判官ぃ 2023-07-13 05:57 5阅读 0赞 ### **我们都知道linux下默认安装的是python2.7.5版本,那么如何安装python3呢** ### 安装步骤如下: (1)wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz 下载安装包 (2)tar zxvf Python-3.6.5.tgz 解压安装包 (3)cd Python-3.6.5 转到该安装包目录下 (4)准备编译环境,执行下面命令 yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make (5)./configure --prefix=/usr/local/python3 指定安装路径 (6) make 编译 (7) make install 安装 但是现在执行python,还是会显示python2.7.5,因为现在usr/bin/python可执行文件指向的python2.7 (8)将默认的python改为python3 8.1 mv /usr/bin/python /usr/bin/python.bak 8.2 ln -s /usr/local/python3/bin/python3.6 /usr/bin/python (9)为了像刚开始没有安装python3之前,不论执行python2还是执行python都会进入python2.7.5的环境一样,为 python3创建软链接 ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3 我这里将软链接指向了usr/bin/python3 现在不论是执行python还是python3都会进入到python3的环境,执行python2自然还会进入到python2的环境 pip3创建软链接 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
还没有评论,来说两句吧...