Python urllib2 problem: Name or service not known

A

Alex Borghgraef

Hi all,

Some time ago I've written some python code to read video data off an
IP camera connected via a router to a laptop. Now I try to run this
code on a different laptop and router combination, but now I can't
access the camera.
Some minimal example code:

import urllib2

url = urllib2.urlopen("http://192.168.1.3/-wvhttp-01-/image.cgi")

This fails and returns the error:

<urlopen error [Errno -2] Name or service not known

When I check further, I cannot access any url via urllib2.urlopen, not
the camera nor the router nor localhost. Pinging them poses no problem
though, and I can access the video feed and the router admin page in
firefox without any issues. I run kubuntu 11.10 on the laptop, the
router is not connected to the internet and serves as dhcp server for
both the laptop and the camera. Any suggestions what may be causing
this? In what manner does urlopen access ip addresses differently from
ping or firefox?
 
S

Steven D'Aprano

Hi all,

Some time ago I've written some python code to read video data off an IP
camera connected via a router to a laptop. Now I try to run this code on
a different laptop and router combination, but now I can't access the
camera.
[...]

Check your web proxy and firewall.
 
A

Alex Borghgraef

Some time ago I've written some python code to read video data off an IP
camera connected via a router to a laptop. Now I try to run this code on
a different laptop and router combination, but now I can't access the
camera.

[...]

Check your web proxy and firewall.

Hmm. Damn. I had disabled the proxy in .bashrc, but apparently the one
in /etc/bash.bashrc was still enabled. Thanks.

I'll still have to find out a way to get this thing working with proxy
enabled if I ever want to connect it to our overall network.
 
A

Alex Borghgraef

I'll still have to find out a way to get this thing working with proxy
enabled if I ever want to connect it to our overall network.

Ok, doing os.environ['http_proxy']='' before importing urllib2 seems
to do the trick for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top