I imported two libraries urllib
and from urllib.request import urlopen
.
The second one is contained in the first
When I went over the code and tried to remove the from urllib.request import urlopen
line , I got this message:
opnerHTMLnum = urllib.request.build_opener()
AttributeError: 'module' object has no attribute 'request'
When I restore the from urllib.request import urlopen
line the code runs .
Can anyone explain why?
import re
#import http.cookiejar
import os.path
#import time
#import urllib3
import urllib
from urllib.request import urlopen
import sys
import smtplib
from email.mime.text import MIMEText
# ...
opnerHTMLnum = urllib.request.build_opener()
from urllib.request import urlopen
givesImportError: No module named request
on Python 2.7. Which version of Python are you using? – Salary