Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79197

Re: Import Doesn't Import

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; '"""': 0.07; 'error:': 0.07; 'urllib2': 0.07; 'string': 0.09; '%s"': 0.09; '2to3': 0.09; 'portions': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'throws': 0.09; 'python': 0.11; '2.7': 0.14; 'language.': 0.14; 'changes': 0.15; '"some': 0.16; '>the': 0.16; 'imports': 0.16; 'it;': 0.16; 'message-id:@4ax.com': 0.16; 'pythonwin': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simplest': 0.16; 'statement)': 0.16; 'supplied': 0.16; 'library': 0.18; 'wed,': 0.18; 'bit': 0.19; 'module': 0.19; 'split': 0.19; 'written': 0.21; '(the': 0.22; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'manual': 0.22; 'print': 0.22; '2.x': 0.24; 'url:home': 0.24; 'fine': 0.24; 'right.': 0.26; 'skip:" 30': 0.26; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'converting': 0.30; 'errors': 0.30; "i'm": 0.30; '3.x': 0.31; 'libraries': 0.31; 'produces': 0.31; 'sep': 0.31; 'file': 0.32; 'probably': 0.32; 'stuff': 0.32; 'url:python': 0.33; '(most': 0.33; 'sources': 0.33; 'totally': 0.33; 'could': 0.34; 'tool': 0.35; 'but': 0.35; 'there': 0.35; 'skip:> 10': 0.36; 'transition': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'error.': 0.37; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'affect': 0.61; 'further': 0.61; 'telling': 0.64; 'more': 0.64; 'different': 0.65; '3.4': 0.84; '2013,': 0.91; 'received:108': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Import Doesn't Import
Date Wed, 15 Oct 2014 22:11:39 -0400
Organization IISS Elusive Unicorn
References <1a3844da-b467-43ba-b34f-3aaa6442d799@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-68-178-170.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14910.1413425511.18130.python-list@python.org> (permalink)
Lines 68
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1413425511 news.xs4all.nl 2850 [2001:888:2000:d::a6]:42875
X-Complaints-To abuse@xs4all.nl
X-Received-Body-CRC 3360850814
X-Received-Bytes 6044
Xref csiph.com comp.lang.python:79197

Show key headers only | View raw


On Wed, 15 Oct 2014 17:40:25 -0700 (PDT), ryguy7272 <ryanshuell@gmail.com>
declaimed the following:


>Fetching URLs
>The simplest way to use urllib2 is as follows:
>import urllib2
>response = urllib2.urlopen('http://python.org/')
>html = response.read()
>
	Works fine in Python 2.7

PythonWin 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit
(AMD64)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for
further copyright information.
>>> import urllib2
>>> response = urllib2.urlopen("http://python.org/")
>>> html = response.read()
>>> print html
<!doctype html>
<!--[if lt IE 7]>   <html class="no-js ie6 lt-ie7 lt-ie8 lt-ie9">
<![endif]-->
<!--[if IE 7]>      <html class="no-js ie7 lt-ie8 lt-ie9"> <![endif]-->
<!--[if IE 8]>      <html class="no-js ie8 lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--><html class="no-js" lang="en" dir="ltr">
<!--<![endif]-->

<head>



>
>It immediately produces this error:
>Traceback (most recent call last):
>  File "C:/Python34/import_web_data.py", line 1, in <module>
>    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!!!!!

	Well, you are using Python 3.4 -- there were significant changes made
in the transition from 2.x to 3.x. 90% of the stuff you find on the web is
probably written against Python 2.x -- if the example uses

	print "some stuff %s" % ("or other",)
if is 2.x, while

	print("some stuff %s" % ("or other",))
if could be 2.x (the extra () don't affect 2.x print statement) but is more
likely to be 3.x (though 3.x likely is also using a different formatter
than the old % string interpolation).

	The best documentation is the supplied help system -- the library
reference manual in particular. Glancing at that would reveal that 3.x does
not have a urllib2 module (and the documentation in 2.7.5 even states:
"""
Note
The urllib2 module has been split across several modules in Python 3 named
urllib.request and urllib.error. The 2to3 tool will automatically adapt
imports when converting your sources to Python 3.
"""
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Import Doesn't Import ryguy7272 <ryanshuell@gmail.com> - 2014-10-15 17:40 -0700
  Re: Import Doesn't Import ryguy7272 <ryanshuell@gmail.com> - 2014-10-15 17:44 -0700
    Re: Import Doesn't Import Dan Stromberg <drsalists@gmail.com> - 2014-10-15 18:19 -0700
    Re: Import Doesn't Import Terry Reedy <tjreedy@udel.edu> - 2014-10-15 22:43 -0400
    Re: Import Doesn't Import Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-16 09:01 +0100
  Re: Import Doesn't Import Chris Angelico <rosuav@gmail.com> - 2014-10-16 11:54 +1100
  Re: Import Doesn't Import Dan Stromberg <drsalists@gmail.com> - 2014-10-15 18:12 -0700
  Re: Import Doesn't Import MRAB <python@mrabarnett.plus.com> - 2014-10-16 02:13 +0100
  Python 3 is the active language, recommended for newcomers (was: Import Doesn't Import) Ben Finney <ben+python@benfinney.id.au> - 2014-10-16 12:35 +1100
  Re: Import Doesn't Import Chris Rebert <clp2@rebertia.com> - 2014-10-15 18:21 -0700
  Re: Import Doesn't Import Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-15 22:11 -0400
  Re: Import Doesn't Import Emile van Sebille <emile@fenx.com> - 2014-10-16 14:29 -0700
  Re: Import Doesn't Import Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-16 18:28 -0400
  Re: Import Doesn't Import Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-16 23:56 +0100

csiph-web