473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

No module named urllib

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
16 7423
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Great idea Dennis, I will look into that.

Thanks,

jh

May 8 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carsten Gehling | last post by:
I've tried to install pso on my webserver and made the first test example. When trying to run it (eg. from the prompt), I get the following error: Traceback (most recent call last): File...
0
by: Carsten Gehling | last post by:
Figured out myself - I just removed the line with "from url import Url" -it doesn't seem to be used anywhere ;-) - Carsten > -----Oprindelig meddelelse----- > Fra:...
2
by: x-herbert | last post by:
Hi, I have a small test to "compile" al litle script as a WMI-Tester. The script include a wmi-wrapper and "insert" the Win32-modeles. here the code: my "WMI-Tester.py" ----- import wmi
0
by: M. Lavasani | last post by:
Hi I am trying to test Python-2.3. Any solution for this problem please: >>>gmake test case $MAKEFLAGS in \ *-s*)...
0
by: F. GEIGER | last post by:
py2exe and datetime -> No module named datetime I've begun to use the stdlib module datetime instead of my home brewn classes. Since then a py2exe app doesn't run anymore: Traceback (most...
1
by: fanbanlo | last post by:
What seems to be the matter? >>> path = "C:\\eclipse\\workspace\\moin134\\docbook\\xslt\\html\\db_compiled.dat" >>> f = file(path) >>> cPickle.load(f) Traceback (most recent call last):...
1
by: ye juan | last post by:
Hi, all I have some questions to ask: 1. How can I add a standard module named "datetime" in Jython when the error happens :"Traceback (innermost last): File "C:\python\test.py", line 3, in...
2
by: Juha S. | last post by:
Hi, I'm trying to use the Python profilers to test my code, but I get the following output for cProfile.run() at the interpreter: Traceback (most recent call last): File "<stdin>", line 1, in...
2
by: emallove | last post by:
I'm running into the below "No modules named _sha256" issue, with a python installed in a non-standard location. $ python Python 2.5.2 (r252:60911, May 20 2008, 09:46:50) on linux2 Type...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.