Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
requests module is not working
#1
hi,
I pip installed requests module and added it to my pydev path in my eclipse project. But when i run the program, I get the following error. Please help !
import requests
r = requests.get( 'https://xkcd.com/' )
print( r )
Error:
Traceback (most recent call last): File "/Users/apple/eclipse-workspace/test_demo/test_package/sqlite_requests.py", line 28, in <module> import requests File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module> import urllib3 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/__init__.py", line 7, in <module> from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 3, in <module> import logging File "/Users/apple/eclipse-workspace/test_demo/test_package/logging.py", line 8, in <module> logging.basicConfig( filename = 'sample.log' , level = logging.DEBUG, format = '%(asctime)s:%(name)s:%(message)s' ) AttributeError: partially initialized module 'logging' has no attribute 'basicConfig' (most likely due to a circular import)
Reply
#2
You have a file "/Users/apple/eclipse-workspace/test_demo/test_package/logging.py". This file shadows the logging module from Standard Library. Remove/rename that file.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Sep-10-2020, 02:36 PM)buran Wrote: You have a file "/Users/apple/eclipse-workspace/test_demo/test_package/logging.py". This file shadows the logging module from Standard Library. Remove/rename that file.

OMG ! You are a saviour. It works perfectly fine now. Could you please explain as to how this code was linked to a different file ? Because i read it on the net that having a different requests.py file might be a problem.But how this file created a problem?
Reply
#4
https://docs.python.org/3/tutorial/modul...earch-path

python looks for modules/packages you try to import in different locations in particular order. it finds your logging.py and try to import it, but this result in error
now documentation states that
Quote:When a module named spam is imported, the interpreter first searches for a built-in module with that name.
logging is built-in module, so I am missing something in this case. maybe someone else will shed some light why this happens.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  POST requests - different requests return the same response Default_001 3 1,899 Mar-10-2022, 11:26 PM
Last Post: Default_001
  Requests module get() incomplete download bobzarm 2 2,486 Feb-17-2021, 04:51 PM
Last Post: bobzarm
  Flask, Posgresql - Multiple requests are not working bmaganti 5 2,669 Feb-20-2020, 03:02 PM
Last Post: bmaganti
  ModuleNotFoundError: No module named "requests" BushFacts 1 5,099 Jan-13-2020, 06:49 AM
Last Post: perfringo
  working with lxml and requests gentoobob 23 11,361 Apr-19-2018, 06:54 PM
Last Post: gentoobob
  An Error in Requests Module pratheep 3 11,868 Feb-06-2018, 05:17 PM
Last Post: pratheep
  Using python requests module and BS4 to login on an Wordpress based website apollo 1 9,369 Feb-06-2018, 01:31 AM
Last Post: metulburr
  disable proxy with requests module metulburr 2 9,491 Apr-05-2017, 02:54 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020