I'm on a macOS with Catalina, running my environment from venv
. I'm trying to import requests
within a Jupyter notebook Python3, but I'm getting the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-95039fbd75c1> in <module>()
----> 1 import requests
ModuleNotFoundError: No module named 'requests'
However, requests
is already installed for Python3:
(venv) 42piratas@Darkseid PLAYGROUND % pip3 install requests
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (2.24.0)
Requirement already satisfied: idna<3,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests) (1.25.10)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from requests) (2020.6.20)
If I try to import requests
from the terminal or from a script, it works for Python3, but it won't work for the native macos Python either. But as I said above, I'm using a Python3 notebook
And just in case, if I run the code below within the notebook...
from platform import python_version
print(python_version())
...I get 3.6.5
UPDATE/FIXED: As pointed out below by @m-z below, my Python3 is v3.8 and Jupyter was running v3.6. To fix this, I had to change one "kernel.json" file, as explained in this thread: Jupyter using the wrong version of python