How to install python requests on macos?
Asked Answered
D

5

6

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.

Doodle answered 19/2, 2020 at 21:19 Comment(0)
Q
4

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
Quittor answered 16/9, 2024 at 14:5 Comment(2)
Warning: No available formula with the name "python-requests". Did you mean python-yq?Cyclopean
@Cyclopean please read the answer - python-requests doesn't exists anymore, you have to install requests via pip in a virtual environment as in the last codeboxQuittor
C
1

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

Candlemas answered 19/2, 2020 at 21:24 Comment(3)
That probably means you don’t have python 3 installed.Candlemas
When I run python3 --version, I get Python 3.7.6. I would think Python3 is installed right?Doodle
Then you might need: brew postinstall python3Candlemas
W
1

Upgrading python3 via brew fixed this issue for me.

brew upgrade python3

And then:

pip3 install requests
Wildwood answered 9/11, 2020 at 17:45 Comment(1)
Error: python-requests has been disabled because it does not meet homebrew/core's requirements for Python library formulae!Barhorst
C
-1

You can even install it by brew:

brew upgrade python3

after that:

brew install python-requests

it will work.

Craniometer answered 2/5, 2024 at 15:38 Comment(3)
Error: python-requests has been disabled because it does not meet homebrew/core's requirements for Python library formulae!Barhorst
Error: python-requests has been disabled because it does not meet homebrew/core's requirements for Python library formulae! It will be disabled on 2024-06-23.Muslin
you have to install the libs in a virtual environment - see my answer belowQuittor
M
-3

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
Mundell answered 10/11, 2023 at 9:41 Comment(1)
There is apt on macos.Isolation

© 2022 - 2025 — McMap. All rights reserved.