How to install pip with Python 3?

后端 未结 21 1236
夕颜
夕颜 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 01:43

    If you use several different versions of python try using virtualenv http://www.virtualenv.org/en/latest/virtualenv.html#installation

    With the advantage of pip for each local environment.

    Then install a local environment in the current directory by:

    virtualenv -p /usr/local/bin/python3.3 ENV --verbose
    

    Note that you specify the path to a python binary you have installed on your system.

    Then there are now an local pythonenvironment in that folder. ./ENV

    Now there should be ./ENV/pip-3.3

    use ./ENV/pip-3.3 freeze to list the local installed libraries.

    use ./ENV/pip-3.3 install packagename to install at the local environment.

    use ./ENV/python3.3 pythonfile.py to run your python script.

    0 讨论(0)
  • 2020-11-22 01:44

    Single Python in system

    To install packages in Python always follow these steps:

    1. If the package is for python 2.x: sudo python -m pip install [package]
    2. If the package is for python 3.x: sudo python3 -m pip install [package]

    Note: This is assuming no alias is set for python

    Through this method, there will be no confusion regarding which python version is receiving the package.

    Multiple Pythons

    Say you have python3 ↔ python3.6 and python3.7 ↔ python3.7

    1. To install for python3.6: sudo python3 -m pip install [package]
    2. To instal for python3.7: sudo python3.7 -m pip install [package]

    This is essentially the same method as shown previously.

    Note 1

    How to find which python, your python3 command spawns:

    ganesh@Ganesh:~$ python3 # Type in terminal
    Python 3.6.6 (default, Sep 12 2018, 18:26:19) # Your python3 version
    [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

    Notice python 3.6.6 in the second line.

    Note 2

    Change what python3 or python points to: https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3

    0 讨论(0)
  • 2020-11-22 01:44

    Please follow below steps to install python 3 with pip:

    Step 1 : Install Python from download here

    Step 2 : you’ll need to download get-pip.py

    Step 3 : After download get-pip.py , open your commant prompt and go to directory where your get-pip.py file saved .

    Step 4 : Enter command python get-pip.py in cmd.

    Step 5 : Pip installed successfully , Verify pip installation by type command in cmd pip --version

    0 讨论(0)
  • I was able to install pip for python 3 on Ubuntu just by running sudo apt-get install python3-pip.

    0 讨论(0)
  • 2020-11-22 01:47

    if you're using python 3.4+

    just type:

    python3 -m pip
    
    0 讨论(0)
  • 2020-11-22 01:47

    This is what I did on OS X Mavericks to get this to work.

    Firstly, have brew installed

    Install python 3.4

    brew install python3
    

    Then I get the latest version of distribute:

    wget https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a
    
    unzip distribute-0.7.3.zip
    cd distribute-0.7.3
    sudo setup.py install
    sudo easy_install-3.4 pip
    sudo pip3.4 install virtualenv
    sudo pip3.4 install virtualenvwrapper
    
    mkvirtualenv py3 
    
    python --version
    Python 3.4.1
    

    I hope this helps.

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