WonBok Lee
WonBok Lee

Reputation: 33

python3.5.5 ImportError: No module named request

I'm learning Python3 with Anaconda and having some problems.

import urllib.request as req
url = "http://www.encar.com"
mem = req.urlopen(url)
print(mem)

when implementing it, vscode output shows line 2, in import urllib.request as req ImportError: No module named request

this is my Anaconda env version

(section2) ➜  section2 conda list
# Name                    Version                   Build  Channel
astroid                   1.6.5                    py35_0  
ca-certificates           2018.03.07                    0  
certifi                   2018.4.16                py35_0  
isort                     4.3.4                    py35_0  
lazy-object-proxy         1.3.1            py35h7293e74_0  
libcxx                    4.0.1                h579ed51_0  
libcxxabi                 4.0.1                hebd6815_0  
libedit                   3.1.20170329         hb402a30_2  
libffi                    3.2.1                h475c297_4  
mccabe                    0.6.1            py35h3f6a9a1_0  
ncurses                   6.1                  h0a44026_0  
openssl                   1.0.2o               h26aff7b_0  
pip                       10.0.1                   py35_0  
pylint                    1.9.2                    py35_0  
python                    3.5.5                h0a44026_3  
readline                  7.0                  hc1231fa_4  
setuptools                39.2.0                   py35_0  
six                       1.11.0           py35h39a4c60_1  
sqlite                    3.24.0               ha441bb4_0  
tk                        8.6.7                h35a86e2_3  
wheel                     0.31.1                   py35_0  
wrapt                     1.10.11          py35ha18cf31_0  
xz                        5.2.4                h1de35cc_4  
zlib                      1.2.11               hf3cbc9b_2  
(section2) ➜  section2 pip list
Package           Version  
----------------- ---------
astroid           1.6.5    
certifi           2018.4.16
isort             4.3.4    
lazy-object-proxy 1.3.1    
mccabe            0.6.1    
pip               10.0.1   
pylint            1.9.2    
setuptools        39.2.0   
six               1.11.0   
wheel             0.31.1   

If I omit .request it seems to work, but I don't know why my code above doesn't work. Please tell me how to implement urllib.request

Upvotes: 0

Views: 489

Answers (1)

Andre Motta
Andre Motta

Reputation: 769

Go on your terminal and type in

pip install urllib

This error is just because you don't have the module installed in your python yet!

Upvotes: 1

Related Questions