Announcement

Collapse
No announcement yet.

Python urllib2 problem: Name or service not known

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Python urllib2 problem: Name or service not known

    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:
    Code:
    import urllib2
    
    url = urllib2.urlopen("http://192.168.1.3/-wvhttp-01-/image.cgi")
    This fails and returns the error:
    Code:
    <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.
    Searching for the problem turned up this discussion on the gentoo forums, which didn't provide any solution but did hint that it might be a system-related problem rather than a coding problem.
    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.
    Last edited by Iskendar; Feb 28, 2012, 04:35 AM.
    I.

    #2
    Never mind it's a proxy problem. I disabled http_proxy in .bashrc for this, but apparently it was also set in /etc/bash.bashrc and I didn't check for that.

    That did leave me with the problem how I could get my code to work with the proxy enabled. But I found that one too, just put
    Code:
    import os
    os.environ['http_proxy']=''
    before importing urllib2.
    I.

    Comment

    Working...
    X