0
I’m trying to learn how to use the library Requests in python, but there is an error that I do not know how to solve, in several tutorials creates the variable r = requests.get('https://api.github.com/events')
but my Vscode shows an error => Module 'requests' has in the get 'Member. Get is not a re methodquests?
Which version of python is using friend? What if you try to run that same command from the command line, other than VSCODE, from the error?
– Murilo Portugal
to using python 3.7.4 and in Idle it runs normally, I’m just confused because Vscode does not accept the method.
– Jean Grijp
How strange, I’m using the version Python 3.6.8 and VSCODE 1.38.0 and I can’t reproduce this error you showed, in mine is recognized normally. Using some extension to python in vscode?
– Murilo Portugal
Using the microsoft python extension, I will try to update Vscode to see if I can solve this.
– Jean Grijp
It’s not a problem in VS Code, but in your file. You named the file as
requests.py
, so when doesimport requests
you are importing the file itself on itself instead of importing the library. As your file does not have aget
defined gives error. Never name your files with names of Python modules.– Woss
Anderson, I have a file called scan_dns_directories.py and it uses requests, and it presents the same error, I believe that is not it, despite being a bad programming practice, but I will change the name of the file kkk.
– Jean Grijp
If the file is in the same directory has exactly the same problem, importing your requests.py file instead of the library. In module name resolution Python will always prioritize local modules before searching for global ones.
– Woss