By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,660 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

No module named urllib

P: n/a
I edited environment varialbes and have added C:\Python25\Lib to
PYTHONPATH but get the no module message when the statement

import urllib

is executed.

Even tried copying the urllib file to my working directory.

Any suggestions?

Thanks,

jh

May 7 '07 #1
Share this Question
Share on Google+
16 Replies


P: n/a
HMS Surprise <jo**@datavoiceint.comwrites:
I edited environment varialbes and have added C:\Python25\Lib to
PYTHONPATH but get the no module message when the statement

import urllib

is executed.

Even tried copying the urllib file to my working directory.

Any suggestions?
No messages is good! :-)

If you got any error messages then you'd have a problem.

--
Jorge Godoy <jg****@gmail.com>
May 7 '07 #2

P: n/a
On May 7, 5:29 pm, Jorge Godoy <jgo...@gmail.comwrote:
HMS Surprise <j...@datavoiceint.comwrites:
I edited environment varialbes and have added C:\Python25\Lib to
PYTHONPATH but get the no module message when the statement
import urllib
is executed.
Even tried copying the urllib file to my working directory.
Any suggestions?

No messages is good! :-)

If you got any error messages then you'd have a problem.

--
Jorge Godoy <jgo...@gmail.com>
Perhaps I should have put qoutes in my sentence.

I get the "no module message named urllib".

May 7 '07 #3

P: n/a
HMS Surprise <jo**@datavoiceint.comwrites:
Perhaps I should have put qoutes in my sentence.
Or I should have read it slowly. ;-)
I get the "no module message named urllib".
Can you please

import sys
print sys.path

and put the answer here on the newsgroup?

--
Jorge Godoy <jg****@gmail.com>
May 7 '07 #4

P: n/a
On May 8, 8:06 am, HMS Surprise <j...@datavoiceint.comwrote:
I edited environment varialbes and have added C:\Python25\Lib to
PYTHONPATH but get the no module message when the statement
That directory should already be in sys.path after a normal Python
install. Likewise the PYTHONPATH environment variable should be
undefined:

DOS_promptset PYTHONPATH
Environment variable PYTHONPATH not defined

What was already in PYTHONPATH before you added something?
Why did you think you needed to change things?
>
import urllib

is executed.

Even tried copying the urllib file to my working directory.

Any suggestions?

May 7 '07 #5

P: n/a
On May 7, 5:45 pm, Jorge Godoy <jgo...@gmail.comwrote:
HMS Surprise <j...@datavoiceint.comwrites:
Perhaps I should have put qoutes in my sentence.

Or I should have read it slowly. ;-)
I get the "no module message named urllib".

Can you please

import sys
print sys.path

and put the answer here on the newsgroup?

--
Jorge Godoy <jgo...@gmail.com>
Thanks for posting.

Ah, there is the problem. Now how to fix it? I am running my program
from maxq which generates jython scripts. It is not looking at my
PYTHONPATH as

sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython']

However I copied the urllib file to the directory with the scripts so
thought it should pick it up there.

jh

May 7 '07 #6

P: n/a
On May 7, 6:00 pm, John Machin <sjmac...@lexicon.netwrote:
On May 8, 8:06 am, HMS Surprise <j...@datavoiceint.comwrote:
I edited environment varialbes and have added C:\Python25\Lib to
PYTHONPATH but get the no module message when the statement

That directory should already be in sys.path after a normal Python
install. Likewise the PYTHONPATH environment variable should be
undefined:

DOS_promptset PYTHONPATH
Environment variable PYTHONPATH not defined

What was already in PYTHONPATH before you added something?
Why did you think you needed to change things?

Only what I added before:
..; c:\maxq\bin\testScripts; c:\maxq\bin;c:\maxq\jython

May 7 '07 #7

P: n/a
Since sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython'] I
copied urllib to c:\maxq\lib\Lib.

Now I get the error -

Traceback (innermost last):
File "<string>", line 5, in ?
File "C:\maxq\lib\Lib\urllib.py", line 1148
_hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
^
SyntaxError: invalid syntax

May 7 '07 #8

P: n/a
HMS Surprise <jo**@datavoiceint.comwrites:
Since sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython'] I
copied urllib to c:\maxq\lib\Lib.

Now I get the error -

Traceback (innermost last):
File "<string>", line 5, in ?
File "C:\maxq\lib\Lib\urllib.py", line 1148
_hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
^
SyntaxError: invalid syntax
>>dict(1, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: dict expected at most 1 arguments, got 2
>>dict(a=1)
{'a': 1}
>>>

--
Jorge Godoy <jg****@gmail.com>
May 7 '07 #9

P: n/a
On May 8, 9:06 am, HMS Surprise <j...@datavoiceint.comwrote:
On May 7, 6:00 pm, John Machin <sjmac...@lexicon.netwrote:
On May 8, 8:06 am, HMS Surprise <j...@datavoiceint.comwrote:
I edited environment varialbes and have added C:\Python25\Lib to
PYTHONPATH but get the no module message when the statement
That directory should already be in sys.path after a normal Python
install. Likewise the PYTHONPATH environment variable should be
undefined:
DOS_promptset PYTHONPATH
Environment variable PYTHONPATH not defined
What was already in PYTHONPATH before you added something?
Why did you think you needed to change things?

Only what I added before:
.; c:\maxq\bin\testScripts; c:\maxq\bin;c:\maxq\jython
You have somehow managed to *REPLACE* the whole of sys.path with those
4 directories. Have you fiddled with PYTHONHOME as well? [You
shouldn't].

Go to a DOS-prompt and type
set PYTHONPATH
set PYTHONHOME
and tell us what you see.

May 7 '07 #10

P: n/a
On May 7, 6:31 pm, Jorge Godoy <jgo...@gmail.comwrote:
HMS Surprise <j...@datavoiceint.comwrites:
Since sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython'] I
copied urllib to c:\maxq\lib\Lib.
Now I get the error -
Traceback (innermost last):
File "<string>", line 5, in ?
File "C:\maxq\lib\Lib\urllib.py", line 1148
_hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
^
SyntaxError: invalid syntax
>dict(1, 1)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: dict expected at most 1 arguments, got 2
>dict(a=1)
{'a': 1}

--
Jorge Godoy <jgo...@gmail.com>
Using the 18.5.2 Examples and a few lines added in

from CompactTest import CompactTest
import sys
print sys.path
import urllib

class login(CompactTest):
# Recorded test actions.
def runTest(self):
self.msg('Test started')

opener = urllib.FancyURLopener({})
f = opener.open("http://www.python.org/")
f.read()
# Code to load and run the test
if __name__ == 'main':
login('login').Run()

May 7 '07 #11

P: n/a
On Mon, 2007-05-07 at 16:24 -0700, HMS Surprise wrote:
Since sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython'] I
copied urllib to c:\maxq\lib\Lib.

Now I get the error -

Traceback (innermost last):
File "<string>", line 5, in ?
File "C:\maxq\lib\Lib\urllib.py", line 1148
_hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
^
SyntaxError: invalid syntax
The urllib.py you're using is not compatible with the Python you're
using. The snippet above uses Python 2.4+ syntax, and Jython's syntax is
at 2.1 (stable) or 2.2 (beta).

--
Carsten Haese
http://informixdb.sourceforge.net
May 7 '07 #12

P: n/a
On May 7, 6:54 pm, Carsten Haese <cars...@uniqsys.comwrote:
On Mon, 2007-05-07 at 16:24 -0700, HMS Surprise wrote:
Since sys.path = ['.', 'C:\\maxq\\lib\\Lib', 'C:\\maxq\\jython'] I
copied urllib to c:\maxq\lib\Lib.
Now I get the error -
Traceback (innermost last):
File "<string>", line 5, in ?
File "C:\maxq\lib\Lib\urllib.py", line 1148
_hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
^
SyntaxError: invalid syntax

The urllib.py you're using is not compatible with the Python you're
using. The snippet above uses Python 2.4+ syntax, and Jython's syntax is
at 2.1 (stable) or 2.2 (beta).

--
Carsten Haesehttp://informixdb.sourceforge.net
Thanks for posting. How does one ensure (or even detect) that their
libraries are compatible?

I loaded this library as part of Python 2.5.

Thanks,

jh

May 8 '07 #13

P: n/a
On Tue, 2007-05-08 at 06:19 -0700, HMS Surprise wrote:
Thanks for posting. How does one ensure (or even detect) that their
libraries are compatible?
You ensure that by taking the library from the version of Python that
you're running.
I loaded this library as part of Python 2.5.
That's too new. Since you're using Jython, you're running either 2.1 or
2.2 depending on whether you've installed the stable version or the beta
version. Go grab a Python distribution of the correct version and get
the modules you need from there. Note this, though:

http://www.jython.org/Project/instal...python-modules :
"Not all the modules form CPython is available in Jython. Some modules
require a C language dynamic link library that doesn't exists in java.
Other modules are missing from Jython just because nobody have had a
need for it before and no-one have tested the CPython module with
Jython. If you discover that you are missing a module, try to copy
the .py file from a CPython distribution to a directory on your Jython
sys.path. If that works you are set. If it doesn't work, try asking on
jython-users mailing list."

To summarize, you could be looking at a rather deep rabbit hole of
possibly unsatisfiable dependencies.

To summarize the summary, are you sure you need to use Jython instead of
standard CPython?

Good luck,

--
Carsten Haese
http://informixdb.sourceforge.net
May 8 '07 #14

P: n/a
To summarize the summary, are you sure you need to use Jython instead of
standard CPython?
Thanks for all your help Carsten, you have been more than patient with
me.

To answer your question I must admit I do not know. I am trying to use
a tool called maxq (maxq.tigris.org) that has limited documentation,
or limited in the depth needed by a python/jython neophyte such as me.
Maxq acts an http proxy and generates jython scripts for playback
testing of web apps. So far I have gained a lot of ground referring to
python documentation and even testing code snippets in python shells.
So lacking the knowledge of what is jython/maxq/python and being of at
best moderate intellect I find myself easily overwhelmed and
generally not sure what must be used where. Maxq does not have a tool
for parsing the web pages, therefore I wanted to add some library
calls to pick off some timestamps I must have. Perhaps I should start
looking for another tool, such as twill maybe.

I will fetch an older python and see if that helps.

Thanks again,

jh

May 8 '07 #15

P: n/a
On May 8, 9:13 am, HMS Surprise <j...@datavoiceint.comwrote:
To summarize the summary, are you sure you need to use Jython instead of
standard CPython?

Thanks for all your help Carsten, you have been more than patient with
me.

To answer your question I must admit I do not know. I am trying to use
a tool called maxq (maxq.tigris.org) that has limited documentation,
or limited in the depth needed by a python/jython neophyte such as me.
Maxq acts an http proxy and generates jython scripts for playback
testing of web apps. So far I have gained a lot of ground referring to
python documentation and even testing code snippets in python shells.
So lacking the knowledge of what is jython/maxq/python and being of at
best moderate intellect I find myself easily overwhelmed and
generally not sure what must be used where. Maxq does not have a tool
for parsing the web pages, therefore I wanted to add some library
calls to pick off some timestamps I must have. Perhaps I should start
looking for another tool, such as twill maybe.

I will fetch an older python and see if that helps.

Thanks again,

jh
Thanks again, Carsten. Using v2.2.3 got me past the urllib error.

jh
May 8 '07 #16

P: n/a
Great idea Dennis, I will look into that.

Thanks,

jh

May 8 '07 #17

This discussion thread is closed

Replies have been disabled for this discussion.