I tried using this string
thepage = urllib.request.urlopen(theurl)
with this
import urllib.request
and I keep getting the following error
Traceback (most recent call last):
File ".\email.py", line 2, in <module>
import urllib.request
File "C:\Users\Alonzo\AppData\Local\Programs\Python\Python35-32\lib\urllib\request.py", line 86, in <module>
import email
File "C:\Users\Alonzo\programming\Email Bot\email.py", line 6, in <module>
thepage = urllib.request.urlopen(theurl)
AttributeError: module 'urllib' has no attribute 'request'
I'm not sure what this problem could be.
OK here is what I think is happening.
When you import urllib.request, one of the first things that happens is that urllib.request tries to import a standard library module called email (this module can be found here). You have a personal module in your project called email ("C:\Users\Alonzo\programming\Email Bot\email.py") which tries to use urllib.request.urlopen which hasn't been defined yet in urllib.request (since that happens only after email is imported).
urllib.request is trying to import your local email module instead of the intended standard library module, which breaks everything.
Try renaming "C:\Users\Alonzo\programming\Email Bot\email.py" to something else like emailbot.py (or anything that doesn't shadow a standard library module or installed module you intend to use) and see if that solves your problem.
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