How to install pip with Python 3?

后端 未结 21 1277
夕颜
夕颜 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:07

    This is the one-liner I copy-and-paste:

    curl https://bootstrap.pypa.io/get-pip.py | python3
    

    Alternate:

    curl -L get-pip.io | python3
    

    From Installing with get-pip.py:

    To install pip, securely download get-pip.py by following this link: get-pip.py. Alternatively, use curl:

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    

    Then run the following command in the folder where you have downloaded get-pip.py:

    python get-pip.py
    

    Warning: Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.

    0 讨论(0)
  • 2020-11-22 02:08

    Here is my way to solve this problem at ubuntu 12.04:

    sudo apt-get install build-essential libncursesw5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev
    

    Then install the python3 from source code:

    wget https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tar.xz
    tar xvf Python-3.4.0.tar.xz
    cd Python-3.4.0
    ./configure
    make
    make test
    sudo make install
    

    When you finished installing all of them, pip3 will get installed automatically.

    0 讨论(0)
  • 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)!

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