Recommended way to install pip(3) on centos7

前端 未结 8 1811
梦如初夏
梦如初夏 2020-12-08 07:12

I am interrested in knowing the recommended way to install pip3 for python3.6 (as of today, may 2018) on current version of centos7 (7.5.1804) and the accepted answer of How

相关标签:
8条回答
  • Pip is not bundled in the EPEL version of python 3.6 for some reason. I assume a decent amount of people (such as me) will find this page because of that.

    $ sudo yum install -y python36
    ...
    $ python36 -m pip
    /usr/bin/python36: No module named pip
    

    So in this case, the setuptools package was the easiest solution.

    $ sudo yum install python36-setuptools
    $ sudo easy_install-3.6 pip
    ...
    $ python36 -m pip --version
    pip 18.0 from /usr/local/lib/python3.6/site-packages/pip-18.0-py3.6.egg/pip (python 3.6)
    
    0 讨论(0)
  • 2020-12-08 07:41
    1. Is pip the same for 3.4+

      No, it's not. A single pip installation serves a single Python distribution (pip2.7/pip3.4/pip3.5 etc).

    2. Since Python 3.5, pip is already bundled with the python distribution, so you can just run python3.6 -m pip instead of pip.

    3. Python 3.6 is not available in CentOS 7 vanilla repo. I usually resort to IUS repo when needing to install a fresh Python on CentOS. It always has the most recent Python version, the current one being 3.6.5. It also offers a correspondent pip package.

      $ yum install https://centos7.iuscommunity.org/ius-release.rpm
      $ yum install python36u python36u-devel python36u-pip
      

      Unfortunately, IUS doesn't offer a package for Python 3.7 yet so if you are looking for Python 3.7 on CentOS 7, building from source is your only option.

    Edit: when yum is not an option

    You should prefer the bootstrapping solution described in this answer as it is the most reliable way to get a working pip installed.

    0 讨论(0)
提交回复
热议问题