Update from V115 to V117 Breaks Python

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
bbmak
Posts: 24
Joined: Sat Oct 03, 2015 8:25 pm

Update from V115 to V117 Breaks Python

Post by bbmak »

Hi,
After I upgrade from V115 to V117, I realize V117 breaks my python script with urllib library.
When I re-write the V115 image, the python is working again.
Not sure is this a bug or something else?

update:
my apt-get update also breaks after update to V117
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Update from V115 to V117 Breaks Python

Post by Fourdee »

bbmak wrote:Hi,
After I upgrade from V115 to V117, I realize V117 breaks my python script with urllib library.
When I re-write the V115 image, the python is working again.
Not sure is this a bug or something else?

update:
my apt-get update also breaks after update to V117
Hi BBmak,

When you say "breaks your python script and apt-get update", please could you provide us with more information. Either a screenshot of the error/issue when it occurs, or a copy and paste over SSH.

With the requested information above, we should be able to assist you :)
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
bbmak
Posts: 24
Joined: Sat Oct 03, 2015 8:25 pm

Re: Update from V115 to V117 Breaks Python

Post by bbmak »

Sure, Thank you for the reply. Here is the output of one of the scripts that I am using to update the noip ddns.
Traceback (most recent call last):
File "noip.py", line 7, in <module>
web_page = urllib.urlopen("http://iptools.bizhat.com/ipv4.php")
File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 350, in open_http
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 812, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 793, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
IOError: [Errno socket error] [Errno -2] Name or service not known
Another script using urllib
Traceback (most recent call last):
File "afraid.py", line 20, in <module>
newip = urllib2.urlopen("http://ip.dnsexit.com/").read().strip()
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Update from V115 to V117 Breaks Python

Post by Fourdee »

Might be related to the recent proxy support in DietPi.

As per this page, please try:
Ok, doing os.environ['http_proxy']='' before importing urllib2 seems
to do the trick for that.
Failing that, try running the script with python 3:

Code: Select all

python3 myscript.py
You might need to:

Code: Select all

apt-get install python3
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
bbmak
Posts: 24
Joined: Sat Oct 03, 2015 8:25 pm

Re: Update from V115 to V117 Breaks Python

Post by bbmak »

Fourdee wrote:Might be related to the recent proxy support in DietPi.

As per this page, please try:
Ok, doing os.environ['http_proxy']='' before importing urllib2 seems
to do the trick for that.
Failing that, try running the script with python 3:

Code: Select all

python3 myscript.py
You might need to:

Code: Select all

apt-get install python3
I tried your suggestions, python3 seems working, but I have to change a lot of my codes in order to make my scripts work in python3.

When I use os.environ['http_proxy']='' before importing urllib2, i got the same output as previous.

using V117 also break my apt-get update. It throws me an error as well.
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Update from V115 to V117 Breaks Python

Post by Fourdee »

bbmak wrote:I tried your suggestions, python3 seems working, but I have to change a lot of my codes in order to make my scripts work in python3.

When I use os.environ['http_proxy']='' before importing urllib2, i got the same output as previous.

using V117 also break my apt-get update. It throws me an error as well.
Strange. Is it possible the urllib2 library you have is only python3 compatible?

The apt-get update error, could you paste the error or screenshot it please? There may be a issue with a repo that is causing this. Could even be linked to your python issue if packages were installed from various repos.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Update from V115 to V117 Breaks Python

Post by Fourdee »

Regarding: http://dietpi.com/phpbb/viewtopic.php?f=11&t=408#p1761

Can you paste the results of the following please:

Code: Select all

cat /etc/apt/sources.list
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
bbmak
Posts: 24
Joined: Sat Oct 03, 2015 8:25 pm

Re: Update from V115 to V117 Breaks Python

Post by bbmak »

Please see image when I perform apt-get update after I updated to V117 from V115.
Attachments
v117 apt-get update.jpg
bbmak
Posts: 24
Joined: Sat Oct 03, 2015 8:25 pm

Re: Update from V115 to V117 Breaks Python

Post by bbmak »

Update: Just realized that ping google.com is not working too, and ping 8.8.8.8 is working.
Attachments
v117 apt-get update2.jpg
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Update from V115 to V117 Breaks Python

Post by Fourdee »

bbmak wrote:Update: Just realized that ping google.com is not working too, and ping 8.8.8.8 is working.
Thanks.

Looks like your DNS isnt working correctly.

Can you paste the contents of this file please:

Code: Select all

cat /etc/network/interfaces
Please remove any WiFi passwords if you have set them, prior to posting.

And:

Code: Select all

route
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Post Reply