centos 下,使用yum配置Python3环境

安装Python3:使用yum安装Python

# 安装最新版本的EPEL
yum install epel-release  
# 安装Python3.6版本
yum install python36
# 安装pip3
yum install python36-pip
# 升级pip3
python3 -m pip install --upgrade pip

FAQ

pip3使用国内源

清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/

note:新版ubuntu要求使用https源,要注意。

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider

这样就会从清华这边的镜像去安装pyspider库

pip 生成和安装requirements.txt

# 生成需求列表
pip3 freeze > requirements.txt
# 安装需求列表
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r equirements.txt

缺少依赖包时的解决方法

如下报错信息,为缺少依赖包;解决时,需要安装对应的依赖包:

ImportError: libXrender.so.1: cannot open shared object file: No such file or directory
  • 解决方法:
    • 查看依赖包
    [root@localhost easy12306]# yum provides libXrender.so.1
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * base: centos.ustc.edu.cn
    * epel: mirrors.yun-idc.com
    * extras: centos.ustc.edu.cn
    * updates: centos.ustc.edu.cn
    libXrender-0.9.10-1.el7.i686 : X.Org X11 libXrender runtime library
    源    :base
    匹配来源:
    提供    :libXrender.so.1
    libXrender-0.9.10-1.el7.i686 : X.Org X11 libXrender runtime library
    源    :@base
    匹配来源:
    提供    :libXrender.so.1
- 搜索对应的安装包
    [root@localhost easy12306]# yum search libXrender
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * base: centos.ustc.edu.cn
    * epel: fedora.cs.nctu.edu.tw
    * extras: centos.ustc.edu.cn
    * updates: centos.ustc.edu.cn
    ============================================================================================================ N/S matched: libXrender ============================================================================================================
    libXrender.i686 : X.Org X11 libXrender runtime library
    libXrender.x86_64 : X.Org X11 libXrender runtime library
    libXrender-devel.i686 : X.Org X11 libXrender development package
    libXrender-devel.x86_64 : X.Org X11 libXrender development package
      名称和简介匹配 only,使用“search all”试试。
- 安装对应的安装包
    [root@localhost easy12306]# yum install libXrender.x86_64
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容