简体   繁体   中英

Install pip on mac failed

So I installed different versions of Pythons on my mac and it seems this is the root of all my problems at the moment. I want to import the module named pyperclip in Mueditor but it always says No module named 'pyperclip'

I read a lot of different other threads and tried to sudo /usr/bin/python get-pip.py But I always get /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'get-pip.py': [Errno 2] No such file or directory Which indicates that it is searching in the wrong directory (not sure with the correct terminology here).

I installed Python 3.8 with homebrew and everything is updated fine.

For context: I started programming with anaconda, deleted it downloaded Python from the official website and am using Mueditor right now while following the tasks in the book 'Automate the boring stuff with Python'.

I am even considering setting up my OSX again... Help is much appreciated!

I read a lot of different other threads and tried to sudo /usr/bin/python get-pip.py But I always get /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'get-pip.py': [Errno 2] No such file or directory Which indicates that it is searching in the wrong directory (not sure with the correct terminology here).

I installed Python 3.8 with homebrew and everything is updated fine.

  1. You need to download the get-pip.py file and then execute that command referencing that file.
    https://bootstrap.pypa.io/get-pip.py

  2. Make sure you are selecting the right Python interpreter. You have multiple installed. You can check their versions with /usr/bin/python -V . In your case /usr/bin/python/ is Python 2.7.

  3. Python 3.8 comes with pip installed. Once you figured out the path of your Python3 interpreter you can do: /path/to/your/python3 -m pip install pyperclip .

Check the Python version:

python --version
python3 --version

Install pip using easy_install on MacOS

easy_install is a Python module bundled with setuptools which gives us the ability to download, build, install and manage Python packages

sudo easy_install pip

Install pip using get-pip.py on MacOS

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

python get-pip.py

or

python3 get-pip.py

Install pip with brew on MacOS

brew install python

If any problems related to the pip usage we will have to relink the python with the following command.

brew unlink python && brew link python
brew unlink python3 && brew link python3

In the end after following any of the above steps, check and verify pip version

pip -V

pip3 -V

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM