当前位置: 首页 > >

CentOS7 yum 安装 pip3 和 python3

发布时间:

关键词:python3 pip3 依赖安装 YUM安装PIP CentOS7


CentOS7 yum 安装 pip3 和 python3

步骤


yum install python3
#上面的命令会自动安装python3、pip3

更新pip3


python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple/
# python3 -m pip --version
pip 20.2.4 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

冗余信息


Installed:
python3.x86_64 0:3.6.8-13.el7
Dependency Installed:
libtirpc.x86_64 0:0.2.4-0.16.el7 python3-libs.x86_64 0:3.6.8-13.el7 python3-pip.noarch 0:9.0.3-7.el7_7
python3-setuptools.noarch 0:39.2.0-10.el7
# which python3 ==> /usr/bin/python3
# which pip3 ==> /usr/bin/pip3
# python3 --version ==> Python 3.6.8
# pip3 --version ==> pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

pip3 基本使用

python3 -m pip list
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple requests
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple paramiko
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple flask

python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple python-dotenv
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple pipenv

python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple flask
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple PyMySQL

python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple kafka-python

python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple fastapi
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple uvicorn

python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple docker

阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

更换为国内下载源

国内源


阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) https://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/


一般都用https,http可能报错



命令行直接添加


python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple requests
如果提示不信任,则
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com requests


python2 同理



修改配置文件


cat ~/.pip/pip.conf #没有这个文件则创建之
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com

requirements.txt

pip的freeze命令用于生成将当前项目的pip类库列表生成 requirements.txt 文件:
pip freeze > requirements.txt

安装requirements.txt中的类库内容
pip install -r requirements.txt

参考资料

https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel
https://packaging.python.org/guides/installing-using-linux-tools/
https://packaging.python.org/tutorials/installing-packages/



友情链接: