Couple days ago i installed a clean Python3 environment using MiniConda. After launching Jupyter Lab and trying to start working with the requests module, i got an import error.
In this post i will show you how to easily troubleshoot requests import errors in your Python development environment of choice, being it Jupyter, PyCharm, Spyder etc’ and distribution.
Troubleshooting the no module named requests error
If you are installing your Python packages manually, not using Anaconda / MiniConda or other prepackaged distribution, it’s easily to use the Python package management utility (PIP) to solve this issue. I’ll go through the steps in a Windows computer, those will be pretty quite similar in macOS or Linux distributions.
- First, go ahead and close your Python editor environment.
- Then open your command line ( Windows: Start >> run >> cmd) or Terminal.
- Now type the following command:
pip install requests
- Next, go ahead and close your command or Terminal window.
- Now go ahead and reopen your Python editor and import requests.
import requests as re
If you are using MiniCond then follow these steps:
- Close your Python editor.
- Hit the Windows icons and type Anaconda Prompt. and hit Enter.
- Then type: conda activate <your_environment_path> and hit Enter. As an example, you’ll type C:\envs\Python3.81
- Then type pip install requests and Enter.
- Re-open your Python Editor and keep coding.
No module named requests – even after i pip install
Issue: you are still getting the import error even after executing the installation using pip or the Anaconda Environment Manager.
Solution: ensure that you have indeed closed your Python editor before importing the package. If still you get and error, reboot your Windows PC and try again.
Warning / Errors when trying to pip install requests
Issue: When trying to import the requests module from the Python package repository, you encounter errors:
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
Solution: most probably you have an issue with your Internet connection. Ensure that you are online and try again.