I have a Python script with just these 2 lines:
import requests
print len(dir(requests))
It prints:
12
48
When I print the actual list dir(requests)
, I get this:
['__author__', '__build__', '__builtins__', '__copyright__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__title__', '__version__']
['ConnectionError', 'HTTPError', 'NullHandler', 'PreparedRequest', 'Request', 'RequestException', 'Response', 'Session', 'Timeout', 'TooManyRedirects', 'URLRequired', '__author__', '__build__', '__builtins__', '__copyright__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__title__', '__version__', 'adapters', 'api', 'auth', 'certs', 'codes', 'compat', 'cookies', 'delete', 'exceptions', 'get', 'head', 'hooks', 'logging', 'models', 'options', 'packages', 'patch', 'post', 'put', 'request', 'session', 'sessions', 'status_codes', 'structures', 'utils']
I'm guessing there are multiple requests
modules or something like that. Please help.
If you see that twice it would mean the script is running twice. If that happens try running the script from the command line instead of spyder. Feb-02-2022, 10:21 AM (This post was last modified: Feb-02-2022, 10:22 AM by mcva.)
You can even run the same configuration multiple times if it has Allow parallel run enabled. In Terminal Tool Window, open two tabs and run your scripts in each; In Python Console Tool Window, again open two tabs, in each import your code and call the program.
You gave your script a name of a standard module or something else that is imported by the requests
package. You created a circular import.
yourscript -> import requests -> [0 or more other modules] -> import yourscript -> import requests again
Because requests
didn't complete importing the first time you get to see these differences in the list of supported objects.
Don't do that. Rename your script to something else and it'll all work.
First one is your own module Second is module for dealing with HTTP requests. Rename ur own module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With