Python in RHEL 8

To install Python2 or 3

yum install python3
 or
yum install python2

Why not just “Python”
[root@ip-172-31-41-9 init.d]# python
-bash: python: command not found
[root@ip-172-31-41-9 init.d]# 

That’s why you can use the alternatives mechanism to enable the unversioned python command system-wide

alternatives --set python /usr/bin/python3
[root@ip-172-31-41-9 init.d]# alternatives --set python /usr/bin/python3
[root@ip-172-31-41-9 init.d]# python
Python 3.6.8 (default, Aug 18 2020, 08:33:21) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Note that this works only for the python command itself. Packages and other commands don’t have configurable unversioned variants. Even if you configure python, the commands yum install python-requests or pip won’t work.

Always use the explicit version in these cases. Better yet, don’t rely on the wrapper scripts for pip, venv and other Python modules that you call from the command line. Instead use python3 -m pip, python3 -m venv, python2 -m virtualenv.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装 requirements.txt 文件中列出的 Python 依赖库,你可以按照以下步骤进行操作: 1. 首先确保你的机器上已经安装了 pip 工具。pip 是 Python 官方推荐的第三方库管理工具,用于在 Python 环境中安装、升级、卸载第三方库。你可以通过在终端中运行以下命令来检查 pip 是否已安装: ``` pip --version ``` 如果没有报错并显示 pip 的版本号,那么 pip 已经安装成功。 2. 确认你的 requirements.txt 文件已经准备好,并位于你的工作目录中。 3. 打开终端,并进入你的工作目录。 4. 运行以下命令来安装 requirements.txt 中列出的依赖库: 对于使用 yum 包管理器的系统(如 CentOS、RHEL): ``` sudo yum install python-devel # for python2.x installs sudo yum install python3-devel # for python3.x installs ``` 对于使用 apt-get 包管理器的系统(如 Ubuntu、Debian): ``` sudo apt-get install python-dev # for python2.x installs sudo apt-get install python3-dev # for python3.x installs ``` 对于使用 pip 的系统: ``` pip install -r requirements.txt ``` 这将会根据 requirements.txt 文件中列出的依赖库信息,自动下载并安装所需的库。 5. 等待安装完成后,你的 Python 依赖库就已经成功安装了。 请注意,根据你的操作系统和 Python 版本,你可能需要选择适合的命令来安装相应的依赖库。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Python 用pip批量安装包 requirements.txt(python查看安装的第三方扩展包)| 利用requirements.txt离线...](https://blog.csdn.net/inthat/article/details/117026589)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [python环境中使用 requirement.txt 安装依赖](https://blog.csdn.net/hbqjzx/article/details/131138022)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值