0

I am trying to import requests

But when I try to run it in PyCharm (or even terminal) I get:

enter image description here

As a note, my PyCharm interpreter is listed as:

enter image description here

Things I've tried.

  • I started by trying sudo pip install requests and sudo pip3 install requests both of which give:

enter image description here

  • Everything here, here, and here

  • uninstalling and reinstalling requests via pip uninstall requests then pip install requests as well as pip3 uninstall requests then pip3 install requests

  • The terminal command pip3 list gives the most recent version of requests enter image description here

  • The terminal commands which python and which python3 both return /Users/chad/opt/anaconda3/bin/python3

I'm on MacOS 11.6 and totally lost.

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
chadathin
  • 73
  • 1
  • 1
  • 8
  • "As a note, my PyCharm interpreter is listed as:" "The terminal commands which python and which python3 both return /Users/chad/opt/anaconda3/bin/python3" Notice how those paths are *different*? If you want the Anaconda install to be your "default" Python, and have `requests` installed there, and then want PyCharm to use that, then the problem is *telling PyCharm about that install*. – Karl Knechtel Oct 22 '21 at 02:52
  • I appreciate the feedback, thank you. I suspected that difference may be an issue, but I don't know how to _not_ make Anaconda the default? I've tried in the past, but it just seems to break everything, so I end up basically nuking the whole thing, uninstalling and reinstalling Anaconda. – chadathin Oct 22 '21 at 03:05
  • Like I said, if you *do* want it to be the default, then just tell PyCharm to use it. – Karl Knechtel Oct 22 '21 at 03:06
  • Okay, thank you for your help. – chadathin Oct 22 '21 at 03:10

2 Answers2

1

If you look at the installation you installed requests for python3.8, but you are trying to run json_test.py with python3.9.

Try installing requests using pip3.9, or use a virtualenv to install all your dependencies and use that to launch your application.

eandersson
  • 25,781
  • 8
  • 89
  • 110
1

click that little + ... then install your package... that will guarantee its the same interpretter pycharm is using

enter image description here

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • This appears to have worked! Thank you so much! I spent my entire morning and part of my afternoon on this. – chadathin Oct 22 '21 at 02:55