Requests module not found - python

I'm trying to run my python code with the the requests module.
This is the code I use:
import requests
res = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": "rhcFvMg9fxSBPoN4TCb7hQ", "isbns": "9781632168146"})
print(res.json())
The following is the error that shows up:
Traceback (most recent call last):
File "/Users/jonathankent/Downloads/project1/test.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
If anyone knows what could be causing this or what I could do to solve it I would be very appreciative.

requests module is not part of python built-in libraries so you have to install it yourself from the command line using pip:
pip install requests

if you are on MacOS try pip3 install requests

Related

Can't import pymatgen.core "No module named 'pymatgen.core'"

I've used pip install pymatgen with Python 3.9.1 on Windows 10 to install pymatgen, but I'm getting the following error:
Traceback (most recent call last):
File "D:\code\pymatgen\pymatgen.py", line 1, in <module>
import pymatgen.core as mg
File "D:\code\pymatgen\pymatgen.py", line 1, in <module>
import pymatgen.core as mg
ModuleNotFoundError: No module named 'pymatgen.core'; 'pymatgen' is not a package
I have also tried to install the previous 2 versions but still getting the same error though I can already see it in the pip list
pymatgen 2022.3.22
What am I missing?
Maybe try using conda ? if this doesn't work then there is definitely some dependencies issue
https://pymatgen.org/installation.html

BS4 module not found

Traceback (most recent call last):
File "d:/project.py", line 2, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
Guys any idea why i get this error.
Ive installed bs4 with cmd and pip
Where do i have to install the module i am really confused
Some of them work and some of them dont
For example, bs4 doesnt but tkinter does

how to solve "ModuleNotFoundError: No module named 'beautifulsoup4'"?

I'm work in Python Idle.
I installed BeautifulSoup4 with "pip install beautifulsoup4" in Powershell, and it works in Powershell's python.
But when I run in Python Idle
# Read Library
from bs4 import BeautifulSoup
error message said
Traceback (most recent call last):
File "C:/Users/umts1202/Desktop/ML/bs-test1.py", line 2, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
I have no idea what to do. Please help me :(

No module named azure.cosmos.cosmos_client

I'm getting the next error while running the example python script of azure cosmos db:
Traceback (most recent call last):
File "CosmosGetStarted.py", line 1, in <module>
import azure.cosmos.cosmos_client as cosmos_client
ImportError: No module named azure.cosmos.cosmos_client
I was trying to do everything according to the next manual:
https://learn.microsoft.com/en-us/azure/cosmos-db/create-sql-api-python
Install the latest azure-cosmos package:
pip3 install --upgrade azure-cosmos
and then import the package like this:
from azure.cosmos import exceptions, CosmosClient, PartitionKey
there are more details in the official package page here
I was able to fix this issue:
Just call "python3.6 CosmosGetStarted.py" and not "python CosmosGetStarted.py"

ModuleNotFoundError: No module named 'urllib3.exceptions'; 'urllib3' is not a package

I'm using the following code to get data from a REST API:
import requests
import json
key = "my service key"
api = "http://api.data.go.kr/openapi/pblprfr-event-info-std?serviceKey=", key, "&s_page=1&s_list=100&type=json"
r = requests.get(api)
data = json.loads(r.text)
print(data["행사명"])
This code produces the following error:
File "sel2.py", line 1, in <module>
import requests
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/init.py", line 46, in <module>
from .exceptions import RequestsDependencyWarning
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/exceptions.py", line 9, in <module>
from urllib3.exceptions import HTTPError as BaseHTTPError
ModuleNotFoundError: No module named 'urllib3.exceptions'; 'urllib3' is not a package
Any ideas what the problem can be?
Most likely something got corrupted in your requests installation or it's dependencies. The following fixed the issue, for me:
# Yeah, do them one-at-a-time, in case of errors:
pip uninstall urllib3
pip install --no-cache-dir -U urllib3
pip uninstall chardet
pip install --no-cache-dir -U chardet

Categories

Resources