QuickLearner
QuickLearner

Reputation: 345

How to install python requests on macos?

I am trying to install the requests package for Python 3.7 on Mac. I already have python 2.7 installed. I have read all the previous questions related to this and none of them could solve the issue.

pip3.7 install requests
bash: pip3.7: command not found
python3.7 -m pip install requests
/usr/local/bin/python3.7: No module named pip

I am not able to understand the issue here.

Upvotes: 10

Views: 31150

Answers (5)

Simon Meyer
Simon Meyer

Reputation: 2044

If you installed python3 via brew, installing python libs globally is not allowed anymore and

pip3 install requests

will fail with "This environment is externally managed" and

brew install python-requests 

will fail with "Error: python-requests has been disabled because it does not meet homebrew/core's requirements for Python library formulae! It was disabled on 2024-06-23"

luckily the solution is stated in the first error message, you have to create a virtual environment instead of a globally installed lib with:

python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install requests

Upvotes: 10

itisMHN
itisMHN

Reputation: 53

You can even install it by brew:

brew upgrade python3

after that:

brew install python-requests

it will work.

Upvotes: -1

Honey
Honey

Reputation: 1

for updating python to the last version do this: first go to python.org and download the latest version of python then run it and do the installation then in the terminal write this =>

python3 --version

it should show the latest version

for installing requests do this:

sudo apt install python3-requests

Upvotes: -5

Jose Jurado
Jose Jurado

Reputation: 319

Upgrading python3 via brew fixed this issue for me.

brew upgrade python3

And then:

pip3 install requests

Upvotes: 1

Jiri Volejnik
Jiri Volejnik

Reputation: 1099

There’s no “pip3.7”, just “pip3”. Try this: pip3 install requests

Upvotes: 1

Related Questions