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/
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: 在CentOS 7上安装Python 3和pip3,可以按照以下步骤进行操作: 1. 更新系统软件包: ``` sudo yum update ``` 2. 安装Python 3: ``` sudo yum install python3 ``` 3. 安装pip3: ``` sudo yum install python3-pip ``` 4. 验证Python 3和pip3是否安装成功: ``` python3 --version pip3 --version ``` 如果输出了版本号,则说明安装成功。 希望对您有帮助! ### 回答2: CentOS 7 默认自带 Python 2.x, 如果需要使用 Python 3.x,需自己手动安装。本文主要介绍 CentOS 7 安装 Python 3 和 pip3 的方法。 一、安装 Python 3 1. 更新系统组件 ``` yum update -y ``` 2. 安装依赖库 ``` yum install gcc openssl-devel bzip2-devel libffi-devel -y ``` 3. 下载 Python 3 源码 ``` cd /usr/src wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz ``` 4. 解压源码包 ``` tar xzf Python-3.8.1.tgz ``` 5. 编译源码安装 ``` cd Python-3.8.1 ./configure --enable-optimizations make altinstall ``` 6. 验证安装是否成功 ``` python3.8 ``` 二、安装 pip3 1. 下载 get-pip.py ``` curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ``` 2. 安装 pip3 ``` python3.8 get-pip.py ``` 3. 验证安装是否成功 ``` pip3 -V ``` 以上就是 CentOS 7 安装 Python 3 和 pip3 的详细步骤,安装过程稍微有些繁琐,但不难操作。安装成功后可以愉快的使用 Python 3 编写代码了。 ### 回答3: CentOS 7作为一种可靠的操作系统,被许多的企业和个人所使用。安装Python3pip3将允许您在CentOS 7上运行Python3应用程序。本文将介绍如何在CentOS 7上安装Python 3和pip3。 首先,打开终端并以root权限登录。 接下来,安装更新: yum update 然后,安装EPEL存储库,这将为我们提供必要的资源。 yum install epel-release 安装Python 3: yum install python3 安装Python3后,需要验证是否自动安装pip3。可以使用以下命令来验证: pip3 --version 如果已安装pip3,则将显示已安装的版本信息。如果pip3没有安装,则需要手动安装。 手动安装pip3,首先需要安装setuptools和pipyum install python3-setuptools 然后安装pip: easy_install-3.6 pip 要验证pip是否已安装,请输入以下命令: pip3 --version 安装成功后,将显示已安装的版本信息。 最后,您可以使用pip3来安装Python软件包和模块: pip3 install package_name 总之,CentOS 7安装Python3pip3很简单,只需要运行上述命令即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凯尔kyle

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值