How to install pip with Python 3?

后端 未结 21 1235
夕颜
夕颜 2020-11-22 01:06

I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.

How can I install pip with Python 3?

21条回答
  •  清酒与你
    2020-11-22 02:09

    Python 3.4+ and Python 2.7.9+

    Good news! Python 3.4 (released March 2014) ships with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Nodejs, Haskell, Perl, Go--almost every other contemporary language with a majority open-source community. Thank you Python.

    Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this at Does Python have a package/module management system?

    Alas for everyone using an earlier Python. Manual instructions follow.

    Python ≤ 2.7.8 and Python ≤ 3.3

    Follow my detailed instructions at https://stackoverflow.com/a/12476379/284795 . Essentially

    Official instructions

    Per https://pip.pypa.io/en/stable/installing.html

    Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt.

    python get-pip.py
    

    You possibly need an administrator command prompt to do this. Follow http://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx

    For me, this installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (eg. C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:

    pip install httpie
    

    There you go (hopefully)!

提交回复
热议问题