• tensorflow需要pip安装的库


    tensorflow需要pip安装的库

    更换pip源到国内镜像
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple

    需要安装的库:
    pip install dingtalkchatbot
    pip install BeautifulSoup4
    pip install pymysql
    pip install matplotlib
    pip install lxml
    pip install tensorflow==1.12.0
    pip install keras==2.2.4
    pip install scikit-learn
    pip install pandas
    查看版本
    pip list
    ==================
    默认安装的是18.1版本的,一般需要升级到19.3.1
    pip3 install --upgrade pip
    pip3环境的要用pip3替换pip

    pip3 install dingtalkchatbot
    pip3 install BeautifulSoup4
    pip3 install pymysql
    pip3 install matplotlib
    pip3 install lxml
    pip3 install tensorflow==1.12.0
    pip3 install keras==2.2.4
    pip3 install scikit-learn
    pip3 install pandas
    查看安装的版本
    pip3 list
    ==================
    linux - python:卸载(实际上不需要卸载旧版本)
    [root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
    [root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
    [root@test ~]# whereis python ##验证删除,返回无结果
    ==================
    Centos7 安装 python 2.7.15 和 pip
    进入到下载目录:
    wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
    tar -zxvf Python-2.7.15.tgz
    cd Python-2.7.15
    ./configure --enable-optimizations
    make
    make install

    # python2 -V
    Python 2.7.15

    ===================
    查看现有python的软连接指向的版本
    ls -l /usr/bin | grep python
    ---------------
    -查找python
    #whereis python
    python: /usr/local/bin/python3.6 /usr/local/bin/python /usr/local/bin/python3.6-config /usr/local/bin/python3.6m-config /usr/local/bin/python2.7-config /usr/local/bin/python3.6m /usr/local/bin/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python2.7
    ----------------
    删除软链接
    rm -rf /usr/bin/python
    rm -rf /usr/bin/pip

    建立新的指向python2.7的软链接
    ln -s /usr/local/bin/python2.7 /usr/bin/python
    ln -s /usr/local/bin/pip /usr/bin/pip

    查看软连接版本
    # python -V
    Python 2.7.15

    ===================

    下载python3.6编译安装
    # wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
    # tar -xzvf Python-3.6.8.tgz
    # cd Python-3.6.8
    把Python3.6安装到 /usr/local 目录
    # ./configure --prefix=/usr/local
    # ./configure --enable-optimizations
    # make
    # make install
    ps:两步不能合并到一步进行,否则会出现很多问题

    测试:python3 -V
    python3.6程序的执行文件:/usr/local/bin/python3.6
    python3.6应用程序目录:/usr/local/lib/python3.6
    pip3的执行文件:/usr/local/bin/pip3.6


    更改/usr/bin/python链接
    # ln -s /usr/local/bin/python3.6 /usr/bin/python 此步骤忽略
    # ln -s /usr/local/bin/python3.6 /usr/bin/python3
    # ln -s /usr/local/bin/pip3.6 /usr/bin/pip3

    =====================
    安装python3的时候会自动安装pip3
    手动安装:
    wget https://pypi.python.org/packages/source/p/pip/pip-9.0.1.tar.gz
    tar -zxvf pip-9.0.1.tar.gz
    (Ps:tar.gz后面不能带有空格,没有安装tar命令先安装:yum install -y tar)
    cd pip-9.0.1
     
    python3 setup.py build
    python3 setup.py install
    ------------
    如果报错:ModuleNotFoundError: No module named 'setuptools'
    需要安装setuptools
    wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz

    tar -zxvf setuptools-19.6.tar.gz
    cd setuptools-19.6
    python3 setup.py build
    python3 setup.py install

    如果报错:RuntimeError: Compression requires the (missing) zlib module
    先安装zlib模块:
    yum install -y zlib
    yum install -y zlib-devel

    进入python3.6的目录,重新编译安装
    make
    make install
    ps:两步不能合并到一步进行

    Collecting pip
    Installing collected packages: setuptools, pip
    Successfully installed pip-18.1 setuptools-40.6.2

    重新编译后会自动安装就不需要再手动安装了,如果没有就重新进入setuptools-19.6目录安装

    默认安装的pip3是18.1版本的,一般需要升级到19.3.1
    pip3 install --upgrade pip
    ==================
    安装lrzsz
    yum -y install lrzsz
    ==================
    ==================
    --查找yum
    #whereis yum
    yum: /etc/yum.conf
    安装yum
    下载:wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
    解压:tar xvf yum-3.2.28.tar.gz

    在etc中创建yum而配置文件yum.conf
    touch /etc/yum.conf
    进入yum的解压目录:cd yum-3.2.28
    运行:./yummain.py install yum
    报错:
    File "/root/sofe/yum-3.2.28/yum/__init__.py", line 23, in <module>
    import rpm
    ==================
    2.卸载yum
      rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
      rm -rf /etc/yum.repos.d/*
      whereis yum|xargs rm -frv

    下载文件:
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

    因文件有相互依赖性,注意顺序,故先安装python-iniparse-*.rpm 文件
    # rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
    # rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    # rpm -ivh yum-3.4.3-154.el7.centos.noarch.rpm
    # rpm -ivh yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
    注:rpm -ivh 要安装的rpm --nodeps --force (加上 --nodeps --force 为強制安裝,不管依赖性文件)

    # rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm --nodeps --force
    # rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --nodeps --force
    # rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm --nodeps --force
    # rpm -ivh yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm --nodeps --force
    安装完之后,可以使用rm 命令删除当前目录下的RPM文件(装完就没有用处了)。

    ===============
    # cd /usr/bin
    [root@darg98 bin]# ls -al | grep python
    lrwxrwxrwx 1 root root 24 Oct 27 23:34 python -> /usr/local/bin/python2.7

    ===============
    # rpm -qa |grep yum
    yum-plugin-fastestmirror-1.1.31-52.el7.noarch
    yum-3.4.3-163.el7.centos.noarch
    yum-metadata-parser-1.1.4-10.el7.x86_64

    # whereis python
    python: /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /usr/local/bin/python3.6 /usr/local/bin/python /usr/local/bin/python3.6-config /usr/local/bin/python3.6m-config /usr/local/bin/python2.7-config /usr/local/bin/python3.6m /usr/local/bin/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python2.7
    vi /usr/bin/yum

    ===============
    python版本变了后 no module named yum有效解决办法
    如果原本依赖的python版本没了,那就只能重新安装yum了;
    yum必须rpm安装,而且还依赖一大堆安装包,一个个装还有顺序关系。
    最简单的办法是将所有的包下载下来,一起强制安装
    下载地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/

    以centos 7 为例子, 不同的操作版本下载对应不同的包(后缀不同 xxxxxx.el7.x86_64)
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-86.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-devel-2.7.5-86.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-86.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-tools-2.7.5-86.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-40.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-aliases-1.1.31-52.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-52.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-52.el7.noarch.rpm
    wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-52.el7.noarch.rpm


    将上面的包放到一个目录下 进入目录 执行 rpm -ivh --force *.rpm --nodeps
    建议先安装 python-*的文件,再安装rpm-python-*的文件,最后安装yum-*的文件
      rpm -ivh --force --nodeps python*.rpm
      rpm -ivh --force --nodeps rpm-python-*.rpm
      rpm -ivh --force --nodeps yum-*.rpm

    测试:
    yum list
    =================
    解决 ModuleNotFoundError: No module named '_bz2'

    在操作系统中安装zlib和bz2相关库
    yum install zlib zlib-devel

    yum -y install bzip2 bzip2-devel ncurses openssl openssl-devel openssl-static xz lzma xz-devel sqlite sqlite-devel gdbm gdbm-devel tk tk-devel libffi-devel

    yum install -y bzip2*

    重新编译python(一般情况遇到奇怪的问题没法解决用重新编译python的方法就可以解决了)
    export CFLAGS="-I/usr/include"
    export LDFLAGS="-L/usr/lib64"
    export LD_LIBRARY_PATH=/usr/lib64
    进入到python3.6安装目录:
    # cd Python-3.6.8/
    make distclean
    ./configure --prefix=/usr/local
    ./configure --enable-optimizations
    make
    make install

    重新编译后就可以了

    =====================

  • 相关阅读:
    【XSY2166】Hope 分治 FFT
    【XSY2612】Comb Avoiding Trees 生成函数 多项式求逆 矩阵快速幂
    【BZOJ1578】【USACO2009Feb】股票市场 背包DP
    【BZOJ2333】【SCOI2011】棘手的操作 treap合并
    【BZOJ1580】【USACO2009Hol】杀手游戏 计算几何
    【BZOJ3379】【USACO2004】交作业 区间DP
    【BZOJ2208】【JSOI2010】连通数 传递闭包
    【BZOJ4033】【HAOI2015】树上染色 树形DP
    【BZOJ3816】【清华集训2014】矩阵变换 稳定婚姻问题
    【XSY2528】道路建设 LCT 可持久化线段树
  • 原文地址:https://www.cnblogs.com/zdz8207/p/tensorflow-pip-libs.html
Copyright © 2020-2023  润新知