centos 7上安装 python3

247 阅读1分钟

前言

实在是受不了 wget 这种下载源码方式编译了, 搞了个骚操作,不知道你们听过anaconda没有

anaconda 官网上去下载一个sh ,这个sh 非常的大

download

我这里直接把这个sh文件拷贝到 docker 里面去了,你们可以自行拷贝到服务器上

# copy to docker 
docker cp /download/Anaconda3-2021.05-Linux-x86_64.sh ${dockerName}:/root

# 安装py3.8
sh Anaconda3-2021.05-Linux-x86_64.sh

# 然后一路回车
# 有一个选项是选择安装路径,我就直接安装到root/py3Anaconda里面了

install anaconda

配置环境变量,默认centos7 是py 2.7.x ,加上py3 版本的Path

vi /etc/profile
# 在最后加上PAth
#Anaconda
export PATH=$PATH:/root/py3Anaconda/bin

# 保存后 source file
source /etc/profile

现在就可以在linux上 找到python3 的commond了

python3 commond

再墨迹一下 搞一个 requirements.txt

touch requirements.txt && vi requirements.txt

requirements.txt 内容

grpcio
grpcio-tools
pypinyin
jieba

使用requirements.txt

pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

退出Anaconda 环境

conda deactivate