centosでpython 2とpython 3が共存する場合、pip 3のインストールと競合の問題

4545 ワード

以前centos 7のバージョンをpython 2からpython 3にアップグレードするために、python 3のバージョンだけを残してcentosのpython 2のバージョンを削除しようとしたが、多くの穴を踏んでlinuxシステムを崩壊させたことが証明された.びっくりして震えた.この2つのバージョンは、対応する/usr/bin/pythonが対応するマシンにpython 2バージョン、/usr/bin/python 3ソフト接続/usr/bin/python 3を持たせる限り共存可能であることが分かった.6でpython 3コマンドでpython 3バージョンを実行できます.
[root@hw007 bin]# python
Python 2.7.5 (default, Oct 30 2018, 23:45:53) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
------------------------------------------------------------------------[root@hw007 bin]# python3
Python 3.6.6 (default, Mar 29 2019, 00:03:27) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

まったくniceですが、python 2に対応するpipとpython 3に対応するpipは違います.python 3に対応するpipはpip 3である.だから、対応するバージョンをもう1つダウンロードする必要があります.次の操作を行います.
wget –no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e6
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6/
python3 setup.py build
python3 setup.py install
wget –no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2/
python3 setup.py build
python3 setup.py install
whereis pip3 #    /usr/bin   pip3,           
sudo ln -sf /usr/local/bin/pip3.6 /usr/bin/pip3 #   
pip3

ソフト接続を実行しないとエラーが表示されます:-bash:/usr/bin/pip 3:No such file or directory)
Usage:   
  pip3  [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging
                              levels).
  --log                 Path to a verbose appending log.
  --proxy              Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries          Maximum number of retries each connection should attempt (default 5 times).
  --timeout              Set the socket timeout (default 15 seconds).
  --exists-action     Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort).
  --trusted-host    Mark this host as trusted, even though it does not have valid or any HTTPS.
  --cert                Path to alternate CA bundle.
  --client-cert         Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir            Store the cache data in .
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
  --no-color                  Suppress colored output

次にpip 3をダウンロードします.
pip3 install paddlepaddle

エラーが発生し、現在のpipバージョンが低すぎることを示します.次のコマンドを実行し、上のコマンドを実行する必要があります.
pip3 install --upgrade pip
sudo ln -sf /usr/local/bin/pip3.6 /usr/bin/pip3
pip3 install paddlepaddle