Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'error:': 0.07; 'importerror:': 0.07; 'urllib2': 0.07; 'explanation': 0.09; 'raises': 0.09; 'throws': 0.09; 'python': 0.11; 'language.': 0.14; 'posted': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'it;': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'simplest': 0.16; 'url:python2orpython3': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'header:User- Agent:1': 0.23; 'url:moin': 0.24; "i've": 0.25; 'right.': 0.26; 'skip:" 30': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'errors': 0.30; "i'm": 0.30; 'url:wiki': 0.31; 'file:': 0.31; 'libraries': 0.31; 'produces': 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'says': 0.33; 'url:python': 0.33; '(most': 0.33; 'link.': 0.33; 'totally': 0.33; 'received:84': 0.35; 'but': 0.35; 'everyone.': 0.36; 'url:org': 0.36; 'error.': 0.37; 'so,': 0.37; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'today.': 0.61; 'new': 0.61; "you're": 0.61; 'here:': 0.62; 'times': 0.62; 'name': 0.63; 'such': 0.63; 'telling': 0.64; 'fire': 0.65; 'here': 0.66 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Ar9g3YNP c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=m9fHe4oz-9sA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=6qcsT95qkLBPafL8wZ0A:9 a=QEXdDO2ut3YA:10 a=KbQsUJdG4wkA:10 X-AUTH: mrabarnett:2500 Date: Thu, 16 Oct 2014 02:13:43 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Import Doesn't Import References: <1a3844da-b467-43ba-b34f-3aaa6442d799@googlegroups.com> In-Reply-To: <1a3844da-b467-43ba-b34f-3aaa6442d799@googlegroups.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413422034 news.xs4all.nl 2953 [2001:888:2000:d::a6]:55832 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79192 On 2014-10-16 01:40, ryguy7272 wrote: > So sorry everyone. I've posted here several times today. This is > VERY frustrating. > > So, I'm reading this link. > https://docs.python.org/2/howto/urllib2.html > > > Fetching URLs > The simplest way to use urllib2 is as follows: > import urllib2 > response = urllib2.urlopen('http://python.org/') > html = response.read() > > > So, I fire up Python, and create a new file and name it and hit F5. > > All I have is thins in the file: > import urllib2 > response = urllib2.urlopen('http://python.org/') > html = response.read() > > It immediately produces this error: > Traceback (most recent call last): > File "C:/Python34/import_web_data.py", line 1, in > import urllib2 > ImportError: No module named 'urllib2' > > > ImportError: No module named 'urllib2' > I'm telling Python to import because it doesn't exist and it throws > an error. I don't get it; I just don't get it. If I'm working with > R, I can import thousands of libraries with no errors whatsoever. > With Python, I just get thousands of errors with nothing working > whatsoever. I totally don't understand this language. Import means > import. Right. WTF!!!!! > It raises an exception because there's no such module as 'urllib2' in Python 3. You're reading the docs here: https://docs.python.org/2/howto/urllib2.html which are for Python 2, but the path you have here: C:/Python34/import_web_data.py says that you're using Python 3.4. There's an explanation of Python 2 vs Python 3 here: https://wiki.python.org/moin/Python2orPython3