You are not logged in.

#1 2013-07-06 13:13:42

hybrid
Member
Registered: 2007-02-05
Posts: 262

python script, "No module named 'new'"

Hi,
I'm trying to run a python hot-corners script from here (at the very bottom of that page). Unfortunately I'm presented the following output:

$ /tmp/hot-corners.py 
Traceback (most recent call last):
  File "/tmp/hot-corners.py", line 6, in <module>
    from Xlib import display
  File "/usr/lib/python3.3/site-packages/Xlib/display.py", line 20, in <module>
    import new
ImportError: No module named 'new'

Google brought up some tech talk on how there is no need to "manually" import new and such, but that didn't help me in how I get that script working. Sure I could comment out "import new" in line 20 in /usr/lib/python3.3/site-packages/Xlib/display.py but then I don't know anything about python and I feel like, if that was the solution because importing the module new has become obsolete, then it would've been fixed upstream. And since it isn't, I'm probably missing somethin.

So can anyone help me out?

Offline

#2 2013-07-06 13:26:44

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: python script, "No module named 'new'"

There seems to be an error in the Python 3 version of Xlib/display.py. They probably naively converted the old Python 2 version to Python 3.

The "python" executable on Arch is Python 3. Whenever you save a script from the internet you should convert the hashbang to explicitly invoke the correct version of the Python interpreter. In your case, change it to

#! /usr/bin/env python2

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2013-07-06 13:58:23

hybrid
Member
Registered: 2007-02-05
Posts: 262

Re: python script, "No module named 'new'"

Thanks for the quick reply. Interpreting the script with python2 as you said works fine.

Offline

#4 2013-07-06 14:02:51

fledermann
Member
From: Bielefeld, Germany
Registered: 2013-06-24
Posts: 49

Re: python script, "No module named 'new'"

python-xlib looks quite dead. Hasn't been updated for 4 years and has been testet with python 1.5 to python 2.6, so it won't work in with python3 (hopefully it does with wothon 2.7).

But I don't know if there's an alternative.

Offline

Board footer

Powered by FluxBB