Error ModuleNotFoundError: No module named in Python
I'm running my code in Python Ver3.9(Window10) and get the error status: ModuleNotFoundError: No module named 'requests', here my code:
import requests
url = "https://google.com"
r = requests.get(url)
print(r.text)
In my program, I have a lot of modules to call, I need a solution to solve it thoroughly on my computer and others too. Help me, many tks guys!
-
S0
Sandeep Kumar Jan 07 2021
Okay, here my solutions :
Step 1: Check the correct module name on this page https://pypi.org/ (redundant, missing, wrong module name characters).
Once you are sure that it is the module you need to install, start the next step.Step 2: Make sure your computer window installed The Pip Python. If not, open Cmd and run the script below:
python get-pip.py
Step 3: Open Cmd or Terminal and run the script like this form:
- Form For Window Cmd: pip install module_name
pip install requests
Below is my code for correctly installing the Modules on the OS versions:
#!/usr/bin/python import os from sys import platform try: import requests #import module_1 #import module_2 except ImportError: #Check The OS versions #pip install module name: 'pip install module_1 module_2' #Version Window if platform == "win32": #Version Windows... try: os.system("pip install requests") except: os.system("python -m pip install requests") elif platform == "linux" or platform == "linux2" or platform == "darwin": #Version Linux/OS X try: os.system("sudo pip install requests") except: os.system("python -m pip install requests")
I hope my solution useful for you, If you still have questions, please comment below for my support:)))
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.