How can I install Python's pip3 on my Mac?

前端 未结 11 1798
春和景丽
春和景丽 2020-12-07 10:05

I\'m trying to install pip3, but I\'m not having any luck. Also, I tried sudo install and it did not work. How could I install pip3 on my Mac?



        
相关标签:
11条回答
  • 2020-12-07 10:53

    To install or upgrade pip, download get-pip.py from the official site. Then run the following command:

    sudo python get-pip.py 
    

    and it will install pip for your python version which runs the script.

    0 讨论(0)
  • 2020-12-07 10:54

    UPDATED - Homebrew version after 1.5

    According to the official Homebrew page:

    On 1st March 2018 the python formula will be upgraded to Python 3.x and a python@2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link --force). We will maintain python2, python3 and python@3 aliases.

    So to install Python 3, run the following command:

    brew install python3
    

    Then, the pip or pip3 is installed automatically, and you can install any package by pip install <package>.


    The older version of Homebrew

    Not only brew install python3 but also brew postinstall python3

    So you must run:

    brew install python3
    brew postinstall python3
    

    Note that you should check the console, as it might get you errors and in that case, the pip3 is not installed.

    0 讨论(0)
  • 2020-12-07 10:54

    I also encountered the same problem but brew install python3 does not work properly to install pip3.

    brre will throw the warning The post-install step did not complete successfully.

    It has to do with homebrew does not have permission to /usr/local

    Create the directory if not exist

    sudo mkdir lib 
    sudo mkdir Frameworks
    

    Give the permissions inside /usr/local to homebrew so it can access them:

    sudo chown -R $(whoami) $(brew --prefix)/*
    

    Now ostinstall python3

    brew postinstall python3
    

    This will give you a successful installation

    0 讨论(0)
  • 2020-12-07 10:55

    You could use Homebrew.

    Then just run:

    brew install python3
    
    0 讨论(0)
  • 2020-12-07 11:01

    I ran the below where <user>:<group> matched the other <user>:<group> for other files in the /usr/local/lib/python3.7/site-packages/ directory:

    sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
    brew postinstall python3
    
    0 讨论(0)
提交回复
热议问题