Python: ImportError no module named urllib
Asked Answered
S

2

0

I just rented a VPS from Linode which has python2.5 and ubuntu 8.04. When I run this command from python shell:

import urllib

I get:

ImportError: No module named urllib

What can be the reason? How can I add this module to python? Isn't it prepackaged with the basic version?

Can it be PYTHONPATH problem?

Spill answered 28/3, 2010 at 8:36 Comment(0)
S
1

Ok, I resolved the issue. Somehow, python-tk package (which includes urllib) was missing.

So the following line fixed the problem

apt-get install python-tk
Spill answered 28/3, 2010 at 8:58 Comment(1)
... This hasn't fixed it for me.Collenecollet
P
-1

I use a later OS, so I don't know if this will help, but just in case:

marcelo@localhost:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 9.10
Release:        9.10
Codename:       karmic
marcelo@localhost:~$ python
Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:54:09) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib # works fine
>>> import sys
>>> sys.path
['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages']
>>> 
Poppy answered 28/3, 2010 at 8:53 Comment(1)
I have Ubuntu 8.04 and python 2.5.Spill

© 2022 - 2024 — McMap. All rights reserved.