centos安装pip Xvfb Selenium

本文介绍了如何在Python 2.6环境下安装pip、Xvfb及Selenium,并提供了详细的命令行步骤。从下载pip到安装Selenium,帮助读者顺利配置自动化测试环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pip安装命令:

 python -V
 wget https://bootstrap.pypa.io/get-pip.py
 python get-pip.py

 

Xvfb安装命令:

 

yum install Xvfb

 

Selenium安装命令:

 

pip install -U selenium

 

 

 

详细操作全部日志:

[root@mysqlserver ~]# python -V
Python 2.6.6
[root@mysqlserver ~]# ls
anaconda-ks.cfg  create_table  Desktop  devicemapper  Documents  Downloads  home  index.html  install.log  install.log.syslog  Music  Pictures  Public  Templates  Videos  zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@mysqlserver ~]# wget https://bootstrap.pypa.io/get-pip.py
--2017-08-21 11:20:55--  https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io... 151.101.72.175
Connecting to bootstrap.pypa.io|151.101.72.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1595408 (1.5M) [text/x-python]
Saving to: “get-pip.py”

100%[====================================================================================================================================================================================================================================>] 1,595,408   2.36M/s   in 0.6s    

2017-08-21 11:21:11 (2.36 MB/s) - “get-pip.py” saved [1595408/1595408]

[root@mysqlserver ~]# ls
anaconda-ks.cfg  create_table  Desktop  devicemapper  Documents  Downloads  get-pip.py  home  index.html  install.log  install.log.syslog  Music  Pictures  Public  Templates  Videos  zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@mysqlserver ~]# python get-pip.py
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting pip
/tmp/tmp4Lh3BY/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
/tmp/tmp4Lh3BY/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 346kB/s 
Collecting setuptools
  Downloading setuptools-36.2.7-py2.py3-none-any.whl (477kB)
    100% |████████████████████████████████| 481kB 797kB/s 
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 1.5MB/s 
Collecting argparse; python_version == "2.6" (from wheel)
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, argparse, wheel
  Found existing installation: argparse 1.2.1
    Uninstalling argparse-1.2.1:
      Successfully uninstalled argparse-1.2.1
Successfully installed argparse-1.4.0 pip-9.0.1 setuptools-36.2.7 wheel-0.29.0
/tmp/tmp4Lh3BY/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
[root@mysqlserver ~]# yum install Xvfb
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Package xorg-x11-server-Xvfb-1.17.4-16.el6.centos.x86_64 already installed and latest version
Nothing to do
[root@mysqlserver ~]# yum -y install libXfont
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Package libXfont-1.5.1-2.el6.x86_64 already installed and latest version
Nothing to do
[root@mysqlserver ~]# yum install xorg-x11-fonts*
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Package xorg-x11-fonts-misc-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-14-100dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-1-75dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-100dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-9-100dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-cyrillic-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-75dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-9-75dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-15-75dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-1-100dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-14-75dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-15-100dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-Type1-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-2-75dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ISO8859-2-100dpi-7.2-11.el6.noarch already installed and latest version
Package xorg-x11-fonts-ethiopic-7.2-11.el6.noarch already installed and latest version
Nothing to do
[root@mysqlserver ~]# pip install -U selenium
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting selenium
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading selenium-3.5.0-py2.py3-none-any.whl (921kB)
    100% |████████████████████████████████| 921kB 737kB/s
Installing collected packages: selenium
Successfully installed selenium-3.5.0
[root@mysqlserver ~]#


 

转载于:https://www.cnblogs.com/boonya/p/7403416.html

<think>嗯,用户想在CentOS安装Python的pip工具。我需要先回忆一下CentOS的不同版本可能需要的不同步骤。比如,CentOS 7和CentOS 8可能有差异。用户可能没有说明具体版本,所以需要覆盖常见情况。 首先,用户可能已经安装了Python,但不确定是否自带pip。根据引用[2],CentOS 7可能需要通过yum安装python-pip,但有时候默认仓库里没有。引用[1]提到用户已经安装pip3,但这里用户可能问的是Python 2还是3的情况。所以需要区分Python版本。 然后,引用[3]中的步骤是手动下载get-pip.py脚本安装,这可能适用于系统自带Python没有pip的情况。比如,如果用户自己编译安装了Python,可能需要用这种方式。 接下来,可能的步骤是先检查系统是否已经有pip。比如,运行pip -V或pip3 -V。如果没有,再根据Python版本选择安装方法。对于Python 2,可能需要用yum install python-pip,但有时候仓库里没有,这时候需要启用EPEL仓库。对于Python 3,可能包名是python3-pip,可以通过yum安装。 另外,用户可能遇到权限问题,需要使用sudo。安装完成后,要验证是否成功,用pip --version确认。如果用户自己安装了Python到自定义路径,可能需要用绝对路径调用pip,如引用[3]中的/usr/local/python3/bin/pip3。 还要注意,有些情况下需要先安装EPEL仓库,特别是CentOS 7。比如,安装EPEL后,才能用yum安装pip。如果用户没有启用EPEL,可能需要先执行yum install epel-release。 总结步骤应该是:检查现有pip,根据Python版本选择安装方法,可能需要启用EPEL,或者手动下载get-pip.py安装。同时,用户可能需要安装Python开发工具,如python-devel,来避免某些依赖错误。 可能的问题还有,用户是否安装了正确的Python版本,或者是否遇到SSL模块问题,这可能需要安装其他依赖包。不过用户的问题主要集中在安装pip,所以先提供基本步骤,再提到常见问题和解决方法。 最后,生成相关问题,比如如何升级pip,如何安装特定包,或者如何解决权限问题,如使用虚拟环境。</think>### 在 CentOS 系统中安装 Python pip 工具的步骤 #### 1. **检查是否已安装 pip** 在终端执行以下命令,验证是否已安装 pip: ```bash pip -V # 检查 Python 2 的 pip pip3 -V # 检查 Python 3 的 pip ``` 如果返回版本信息(如 `pip 9.0.3 from ...`),说明已安装[^1]。 #### 2. **通过 yum 安装 pip** - **Python 2 的 pip**: ```bash sudo yum install epel-release # 启用 EPEL 仓库(CentOS 7 需要) sudo yum install python-pip # 安装 pip for Python 2 ``` 如果提示 `No package python-pip available`,需先启用 EPEL 仓库[^2]。 - **Python 3 的 pip**: ```bash sudo yum install python3-pip # 直接安装 pip for Python 3 ``` #### 3. **手动安装 pip(通用方法)** 如果 yum 安装失败(如自定义 Python 路径),可通过脚本安装: ```bash # 下载安装脚本 curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 为 Python 2 安装 sudo python2 get-pip.py # 为 Python 3 安装 sudo python3 get-pip.py ``` 安装后,通过 `pip --version` 或 `pip3 --version` 验证[^3]。 #### 4. **配置环境变量(可选)** 如果 pip 安装到自定义路径(如 `/usr/local/python3/bin`),需添加到 `PATH`: ```bash echo 'export PATH="/usr/local/python3/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` #### 5. **常见问题处理** - **依赖缺失**:安装开发工具包: ```bash sudo yum groupinstall "Development Tools" sudo yum install python-devel # Python 2 sudo yum install python3-devel # Python 3 ``` - **SSL 错误**:更新 OpenSSL 和 CA 证书: ```bash sudo yum update openssl ca-certificates ``` --- §§ 相关问题 §§ 1. 如何在 CentOS 中升级 pip 到最新版本? 2. 使用 pip 安装包时出现权限错误如何解决? 3. 如何为特定 Python 版本创建虚拟环境?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值