Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

NEWB problem with urllib2

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


powderdrop at gmail

Nov 9, 2009, 3:29 PM

Post #1 of 3 (185 views)
Permalink
NEWB problem with urllib2

I just installed PyDev into Eclipse using the 'update' method and did
the standard installation. I allowed it to Auto Configure itself and
ran a "Hello World" module to make sure I was in the ballpark.

I got an starting module up and have run "Hello World" but now am
stuck on getting urlopen to import from urllib2 for the following
example.

from urllib2 import * # doesn't give me an error
ur = urlopen("http://www.daniweb.com/forums/thread161312.html") #
gives me Undefined Variable: urlopen

so I tried just

import urllib2 # Eclipse gives "Unresolved Import"

Is urllib2 not on my path? Isn't urllib2 in the standard installation
and shouldn't that automatically be on my path? If not, how can I get
it on the path?

ThankS!!

--
http://mail.python.org/mailman/listinfo/python-list


sajmikins at gmail

Nov 9, 2009, 5:39 PM

Post #2 of 3 (165 views)
Permalink
Re: NEWB problem with urllib2 [In reply to]

On Mon, Nov 9, 2009 at 6:29 PM, Penn <powderdrop [at] gmail> wrote:
> I just installed PyDev into Eclipse using the 'update' method and did
> the standard installation.  I allowed it to Auto Configure itself and
> ran a "Hello World" module to make sure I was in the ballpark.
>
> I got an starting module up and have run "Hello World" but now am
> stuck on getting urlopen to import from urllib2 for the following
> example.
>
> from urllib2 import *    # doesn't give me an error
> ur = urlopen("http://www.daniweb.com/forums/thread161312.html") #
> gives me Undefined Variable: urlopen
>
> so I tried just
>
> import urllib2        # Eclipse gives "Unresolved Import"
>
> Is urllib2 not on my path?  Isn't urllib2 in the standard installation
> and shouldn't that automatically be on my path?  If not, how can I get
> it on the path?
>
> ThankS!!

This sounds more like a PyDev and/or Eclipse problem than an urllib2 problem. :)

One thing you can check: open the "raw" python interpreter outside of
Eclipse and try importing urllib2 there. You might also try the
interpreter interface within Eclipse (if it provides one.)

HTH
--
http://mail.python.org/mailman/listinfo/python-list


powderdrop at gmail

Nov 9, 2009, 5:48 PM

Post #3 of 3 (165 views)
Permalink
Re: NEWB problem with urllib2 [In reply to]

Thanks Simon!

You are right.. I also believe it is something with Eclipse.

I've been working since... the module below runs.. but Eclipse is
still showing an error when I reference urlopen with a little red X...
saying it is an undefined variable in the IDE.. but not giving me an
runtime errors.




#URL LIBRARY
from urllib2 import *


def openfilereadaline(a):

f = open(a)
print f
for line in f:
print line.rstrip()
f.close()

def openWebSite(a):

ur = urlopen(a) #open url
contents = ur.readlines()#readlines from url file
fo = open("test.txt", "w")#open test.txt
for line in contents:
print "writing %s to a file" %(line,)
fo.write(line)#write lines from url file to text file
fo.close()#close text file

if __name__ == '__main__':

openWebSite("http://www.daniweb.com/forums/thread161312.html")

print "Hello World"
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.