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?

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

Similar Messages

  • Python setuptools gives 'ImportError: No module named version' error

    I am trying to install hdctools-git from AUR and it fails in install() with following error. This package was fine last time I installed it about 2 months ago. My gut feeling says the error comes either from recent python2-setuptools or python2 package update. But my python skills are not good enough to figure out how to solve the problem.
    Does anybody know what is going here?
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/bbgpio_unittests.py to bbgpio_unittests.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/gpio_interface.py to gpio_interface.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/uart.py to uart.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/client.py to client.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/bbuart_unittests.py to bbuart_unittests.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/bbadc.py to bbadc.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/bbmux_controller.py to bbmux_controller.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/system_config.py to system_config.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/bbgpio.py to bbgpio.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/ftdigpio.py to ftdigpio.pyc
    byte-compiling /home/anatol/tmp/pkgs/hdctools-git/pkg/hdctools-git/usr/lib/python2.7/site-packages/servo/bbi2c_unittests.py to bbi2c_unittests.pyc
    writing byte-compilation script '/tmp/tmp4TA67u.py'
    /usr/bin/python2 -O /tmp/tmp4TA67u.py
    removing /tmp/tmp4TA67u.py
    running install_egg_info
    running egg_info
    writing build/servo.egg-info/PKG-INFO
    writing top-level names to build/servo.egg-info/top_level.txt
    writing dependency_links to build/servo.egg-info/dependency_links.txt
    writing entry points to build/servo.egg-info/entry_points.txt
    Traceback (most recent call last):
      File "setup.py", line 28, in <module>
        'dut-control = servo.dut_control:main',
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python2.7/distutils/command/install.py", line 575, in run
        self.run_command(cmd_name)
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/site-packages/setuptools/command/install_egg_info.py", line 33, in run
        self.run_command('egg_info')
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 171, in run
        writer = ep.load(installer=installer)
      File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2310, in load
        return self.resolve()
      File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2316, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
    ImportError: No module named version
    ==> ERROR: A failure occurred in package().
        Aborting...
    Last edited by anatolik (2015-01-18 06:39:16)

    I am getting the same problem. Uninstalling python2-daemon fixed it for me, as suggested here: http://stackoverflow.com/a/27996309/646735
    I have also logged an upstream issue here: https://bitbucket.org/pypa/setuptools/i … ed-version

  • Call an ABAP program or a function module from command prompt/python script

    Dear All,
    I want to call a function module/ABAP program from command prompt or a python script.
    Let me explain with an example.
    There is a function module "z_add" that takes  two integers as input parameters and generates their sum.
    the sum is the output parameter.
    Now i want to call this function module from command prompt / python script and pass parameters to this function module.
    In return i must get the sum(i.e. the output of function module).
    I tried using STARTRFC ,was able to call the FM but could not get the return value(output) from FM.
    Can you please provide me the code of such a function module and the method to call it thereby passing parameters and getting the sum.
    Thanks and regards,
    Gaurav
    Edited by: gauravkec2005 on Mar 4, 2010 7:41 AM

    thank you both!  helpful answers! :o)
    anyway! 
    i have written the program which is called from the SAPScript:
        /:       PERFORM GET_VATNUMBER IN PROGRAM ZFI_F140_OPERATIONS
        /:       USING &BKPF-BUKRS&
        /:       CHANGING &VATNUMBER&
        CE       VAT Registration No : &VATNUMBER&
        REPORT zfi_f140_operations.
        FORM get_vatnumber TABLES in_par  STRUCTURE itcsy
                                  out_par STRUCTURE itcsy.
          DATA: lv_co_code TYPE bukrs,
                lv_vat_no  TYPE stceg.
          READ TABLE in_par WITH KEY name = 'BKPF-BUKRS'.
          MOVE in_par-value TO lv_co_code.
          SELECT SINGLE stceg FROM t001
            INTO lv_vat_no WHERE bukrs = lv_co_code.
          out_par-name = 'VATNUMBER'.
          WRITE lv_vat_no TO out_par-value.
          CONDENSE out_par-value.
          MODIFY out_par INDEX 1.
        ENDFORM.              
    it is not working and i cannot work out why... 
    i have not been ABAPing for very long but have had a go.... 
    any thoughts as to what i have done wrong?
    or point me where i should be looking?  thank you!

  • Superkaramba Python "No module named os"

    When starting themes in Superkaramba, I receive the following error:
    [dave@myhost ~]$ superkaramba
    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
    'import site' failed; use -v for traceback
    superkaramba: TaskManager::TaskManager()
    Traceback (most recent call last):
    File "/home/dave/OSXDocker/OSXDocker.py", line 4, in ?
    import os
    ImportError: No module named os
    According to this page http://www.bscw.de/english/faq/faq_i11.html, a library of python needs to be set properly during build.  Any idea how to correct these errors?

    dave.roberts wrote:How do we vote for such packages?
    check this out: http://bbs.archlinux.org/viewtopic.php?t=11605
    dave.roberts wrote:
    Maybe this could be made more useful if there was "automatic voting" or a hit to a counter on a server every time a user installs the package via pacman.  If some package has many many downloads / installs via pacman, it would be wise to include it in the official repository.
    I know it's easy to spout off ideas without backing them with coding or implementation ideas, but it seems useful.
    I proposed this on the mailing list when they released AUR (today)... it sounds interesting, however, due to numerous mirrors, it's almost impossible... especially if one mirror fails and pacman goes to the next, it would record 2 "votes" for that package...
    Xentac brought up the idea of incorporating it into archstats, as that records installed packages... which could be promising... we'll see what develops

  • Python: no module named struct

    Ever since I performed an update (for x86_64, if that makes a difference) this afternoon, beryl-settings has failed to start for me. It always fails with this message:
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
    Traceback (most recent call last):
      File "/usr/bin/beryl-settings", line 12, in ?
        import gettext
      File "/usr/lib/python2.4/gettext.py", line 49, in ?
        import locale, copy, os, re, struct, sys
    ImportError: No module named struct
    /usr/lib/python2.4/gettext.py belongs to the python package, so I'm supposing the breakage has something to do with that? Pacman says that I currently have python-2.4.4-1.1 installed.

    When I try to run beryl-manager the next error occurs.
    Could not find platform independent libraries <prefix>
    Could not find platform dependent libraries <exec_prefix>
    Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
    'import site' failed; use -v for traceback
    Traceback (most recent call last):
    File "/usr/bin/beryl-settings", line 2, in ?
    import berylsettings
    ImportError: No module named berylsettings

  • [Solved] No module named parse- python errors as own user

    A number of applications on my system (wicd and turpial, among others) return python errors when I run them as my own user. I can run these applications as root with no errors, so I'm not missing any packages. The most common of these errors, appearing when I run applications like turpial and hotot looks like this:
    ➤ turpial
    Traceback (most recent call last):
    File "/usr/bin/turpial", line 5, in <module>
    from pkg_resources import load_entry_point
    File "/usr/lib/python3.3/site-packages/pkg_resources.py", line 17, in <module>
    from urllib.parse import urlparse, urlunparse
    ImportError: No module named parse
    When I run wicd-curses:
    ➤ wicd-curses
    Traceback (most recent call last):
    File "/usr/share/wicd/curses/wicd-curses.py", line 44, in <module>
    from dbus import DBusException
    File "/usr/lib/python3.3/site-packages/dbus/__init__.py", line 82, in <module>
    import dbus.types as types
    File "/usr/lib/python3.3/site-packages/dbus/types.py", line 6, in <module>
    from _dbus_bindings import (
    ImportError: /usr/lib/python3.3/site-packages/_dbus_bindings.so: undefined symbol: PyBytes_Type
    Again, both applications mentioned here work fine when run as root. It should also be noted that I only installed turpial after already witnessing this error with hotot-gtk3-git. Has anyone seen this before, or have any idea how to start troubleshooting it?
    Thanks.
    EDIT: It was a Pythonpath issue.
    Last edited by apurplermixture (2013-04-24 00:55:28)

    Thank you! That worked

  • Python doesn't run and I got this error: "ImportError: No module named site".

    After installing lion python still was working but a new version was added and I don't know exactly what happend that no python scripts were able to run on my macbook. It might be because of path setting but I check many options such as setting PYTHONPATH enviroment variable, however it help a bit and now python is started but still couldn't run the spripts I was running them before.
    This issure blocks all my development tasks.

    The out of the commad find /System/Library/Frameworks/Python.framework -type f -name site.py* -ls:
    8256584       32 -rw-r--r--    1 root             wheel               12354 Jun 14 07:21 /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.py
    6020145       16 -rw-r--r--    1 root             wheel               12151 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.pyc
    6020146       16 -rw-r--r--    1 root             wheel               12151 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site.pyo
    6021735        0 -rw-r--r--    1 root             wheel                3585 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2a pp/apptemplate/lib/site.py
    6021736        0 -rw-r--r--    1 root             wheel                3325 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2a pp/apptemplate/lib/site.pyc
    6021776        0 -rw-r--r--    1 root             wheel                3042 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2a pp/bundletemplate/lib/site.py
    6021777        0 -rw-r--r--    1 root             wheel                3062 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2a pp/bundletemplate/lib/site.pyc
    6021911        0 -rw-r--r--    1 root             wheel                2362 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/site .py
    6021912        0 -rw-r--r--    1 root             wheel                1855 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/site .pyc
    6021913        0 -rw-r--r--    1 root             wheel                1983 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/site .pyo
    8252446       32 -rw-r--r--    1 root             wheel               14620 Jun 17 10:01 /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site.py
    6011169       16 -rw-r--r--    1 root             wheel               16285 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site.pyc
    6011170       16 -rw-r--r--    1 root             wheel               16285 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site.pyo
    6022794        0 -rw-r--r--    1 root             wheel                3645 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2a pp/apptemplate/lib/site.py
    6022795        0 -rw-r--r--    1 root             wheel                3385 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2a pp/apptemplate/lib/site.pyc
    6022836        0 -rw-r--r--    1 root             wheel                3043 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2a pp/bundletemplate/lib/site.py
    6022837        0 -rw-r--r--    1 root             wheel                3056 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/py2a pp/bundletemplate/lib/site.pyc
    6022987        0 -rw-r--r--    1 root             wheel                2362 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site .py
    6022988        0 -rw-r--r--    1 root             wheel                1855 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site .pyc
    6022989        0 -rw-r--r--    1 root             wheel                1983 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site .pyo
    8253860       40 -rw-r--r--    1 root             wheel               19163 Jun 17 10:03 /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site.py
    6014231       24 -rw-r--r--    1 root             wheel               20581 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site.pyc
    6014232       24 -rw-r--r--    1 root             wheel               20581 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site.pyo
    6023870        0 -rw-r--r--    1 root             wheel                3645 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2a pp/apptemplate/lib/site.py
    6023871        0 -rw-r--r--    1 root             wheel                3334 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2a pp/apptemplate/lib/site.pyc
    6023912        0 -rw-r--r--    1 root             wheel                3043 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2a pp/bundletemplate/lib/site.py
    6023913        0 -rw-r--r--    1 root             wheel                3009 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2a pp/bundletemplate/lib/site.pyc
    6024063        0 -rw-r--r--    1 root             wheel                2362 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/site .py
    6024064        0 -rw-r--r--    1 root             wheel                1809 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/site .pyc
    6024065        0 -rw-r--r--    1 root             wheel                1937 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/site .pyo
    8255408       40 -rw-r--r--    1 root             wheel               19929 Jun 17 10:03 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py
    6017466       24 -rw-r--r--    1 root             wheel               21430 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc
    6017467       24 -rw-r--r--    1 root             wheel               21430 Jul 21 14:06 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyo
    Last night my colleague and I spent a while working on the issue, apparantly a sofware has set PYTHONPATH env variable and it causes the problem. How can I get rid of the variable permanently?
    Thanks.

  • Mavericks (10.9.3) Python shelve error: ImportError: No module named _bsddb

    Hi when I updated my OS X to Mavericks (10.9.3), my python couldn't recognize bsddb anymore, which worked fine for my previous versions. This is very annoying since it wasted a whole day of mine without a solution.
    I urge Apple support to give me an answer as QUICK as possible.
    I have tried a lot of possible fixes on StackOverflow, and I have bsddb installed on my computer, and bsddb3 package. Also I followed this tutorial to fix the import issues (which worked before I updated my OS).
    http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-b sddb-modules-to-work/
    Please let me know a solution, this is urgent and I can't waste time on this anymore.

    carebearboy wrote:
    I get this error when attempting to import pygame:
    Python 3.2.1 (default, Jul 11 2011, 12:37:47)
    [GCC 4.6.1] on linux2
    Type "copyright", "credits" or "license()" for more information.
    >>> ================================ RESTART ================================
    >>>
    Traceback (most recent call last):
    File "/home/user/Documents/fun.py", line 3, in <module>
    import pygame, sys, random
    ImportError: No module named pygame
    >>>
    I've tried installing:
    python3-pygame
    python3-pygame2
    python-pygame
    and a couple others...
    Either I get the same error or the install yaourt aborts due to a bad compile. I noticed that I have python 2.7 also installed on my computer.
    Have you tried python3-pygame-svn?
    I'm not a pygame user myself, but it built okay for me, and I was able to import it in python3 with no errors.
    EDIT: just noticed that the pkgbuild is missing a dependency: python-numpy.
    Last edited by kachelaqa (2011-08-28 19:42:06)

  • Python script named in output of ps -u user

    Does anyone here know how I can have a Python script report it's name in the output of "ps -u user", instead of just showing up as "Python"?
    Reason I'm asking is that I just found this nifty little menu program called pytmenu on the Ubuntu forums, and I want it to start in the center of my screen. Problem is, I'm using Evilwm, so I can do it either with switches passed to Evilwm or Devil's Pie, but I need to know the programs name to do it. Passing "Python" as the name will probably not get me the results I want.

    oh. also.. if you want to change the process name from within python..
    http://davyd.livejournal.com/166352.html

  • Python script to parse 'iwlist scan' into a table

    Hi,
    I've written a small python script that parses the output of the command "iwlist interface scan" into a table.
    Why ?
    Like many arch linux users I think, I use netcfg instead of something like network manager or wicd. So the most natural way to scan for wifi networks in range is iwlist scan. But the output of this command is huge and I find it difficult to retrieve information. So this script parses it into a table : one network, one line.
    Example output
    Name Address Quality Channel Encryption
    wifi_1 01:23:45:67:89:AB 100 % 11 WPA v.1
    wifi_2 01:23:45:67:89:AC 76 % 11 WEP
    wifi_3 01:23:45:67:89:AD 51 % 11 Open
    wifi_4 01:23:45:67:89:AE 50 % 11 WPA v.1
    wifi_5 01:23:45:67:89:AF 43 % 4 Open
    wifi_6 01:23:45:67:89:AG 43 % 4 WPA v.1
    Details
    It reads from stdin so you use it like that: iwlist wlan0 scan | iwlistparse.py
    The width of the columns is determined by what's in it.
    You can easily do a bit more than just parsing the info: in the example above, the quality has been calculated to percents from a ratio (e.g. 46/70).
    It is sorted, too.
    Customization
    It's python so it's easy to customize. See the comments in the code.
    Code
    #!/usr/bin/env python
    # iwlistparse.py
    # Hugo Chargois - 17 jan. 2010 - v.0.1
    # Parses the output of iwlist scan into a table
    import sys
    # You can add or change the functions to parse the properties of each AP (cell)
    # below. They take one argument, the bunch of text describing one cell in iwlist
    # scan and return a property of that cell.
    def get_name(cell):
    return matching_line(cell,"ESSID:")[1:-1]
    def get_quality(cell):
    quality = matching_line(cell,"Quality=").split()[0].split('/')
    return str(int(round(float(quality[0]) / float(quality[1]) * 100))).rjust(3) + " %"
    def get_channel(cell):
    return matching_line(cell,"Channel:")
    def get_encryption(cell):
    enc=""
    if matching_line(cell,"Encryption key:") == "off":
    enc="Open"
    else:
    for line in cell:
    matching = match(line,"IE:")
    if matching!=None:
    wpa=match(matching,"WPA Version ")
    if wpa!=None:
    enc="WPA v."+wpa
    if enc=="":
    enc="WEP"
    return enc
    def get_address(cell):
    return matching_line(cell,"Address: ")
    # Here's a dictionary of rules that will be applied to the description of each
    # cell. The key will be the name of the column in the table. The value is a
    # function defined above.
    rules={"Name":get_name,
    "Quality":get_quality,
    "Channel":get_channel,
    "Encryption":get_encryption,
    "Address":get_address,
    # Here you can choose the way of sorting the table. sortby should be a key of
    # the dictionary rules.
    def sort_cells(cells):
    sortby = "Quality"
    reverse = True
    cells.sort(None, lambda el:el[sortby], reverse)
    # You can choose which columns to display here, and most importantly in what order. Of
    # course, they must exist as keys in the dict rules.
    columns=["Name","Address","Quality","Channel","Encryption"]
    # Below here goes the boring stuff. You shouldn't have to edit anything below
    # this point
    def matching_line(lines, keyword):
    """Returns the first matching line in a list of lines. See match()"""
    for line in lines:
    matching=match(line,keyword)
    if matching!=None:
    return matching
    return None
    def match(line,keyword):
    """If the first part of line (modulo blanks) matches keyword,
    returns the end of that line. Otherwise returns None"""
    line=line.lstrip()
    length=len(keyword)
    if line[:length] == keyword:
    return line[length:]
    else:
    return None
    def parse_cell(cell):
    """Applies the rules to the bunch of text describing a cell and returns the
    corresponding dictionary"""
    parsed_cell={}
    for key in rules:
    rule=rules[key]
    parsed_cell.update({key:rule(cell)})
    return parsed_cell
    def print_table(table):
    widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic
    justified_table = []
    for line in table:
    justified_line=[]
    for i,el in enumerate(line):
    justified_line.append(el.ljust(widths[i]+2))
    justified_table.append(justified_line)
    for line in justified_table:
    for el in line:
    print el,
    print
    def print_cells(cells):
    table=[columns]
    for cell in cells:
    cell_properties=[]
    for column in columns:
    cell_properties.append(cell[column])
    table.append(cell_properties)
    print_table(table)
    def main():
    """Pretty prints the output of iwlist scan into a table"""
    cells=[[]]
    parsed_cells=[]
    for line in sys.stdin:
    cell_line = match(line,"Cell ")
    if cell_line != None:
    cells.append([])
    line = cell_line[-27:]
    cells[-1].append(line.rstrip())
    cells=cells[1:]
    for cell in cells:
    parsed_cells.append(parse_cell(cell))
    sort_cells(parsed_cells)
    print_cells(parsed_cells)
    main()
    I hope you find it useful. Please report bugs, I haven't tested it a lot. You may have to customize it though, because I think not all iwlist scan outputs are the same. Again, see comments, it should be easy.

    This tool is very helpfull. I am trying to add a new function to the existing code to parse the signal level parameter from the output of iwlist wlan0 scan, but I am getting lot of issues .Since I am new to python script can anyone help me to extract the signal level also from the scan put put.
    The parametr to be used is Signal level=-44 dBm ,I am trying to create a one more column with Signal level and print its out in the table.
    Example:-
    Signal level
    -44db
    The error I am getting
      File "iwlist_parser_Testing.py", line 146, in <module>
        main()
      File "iwlist_parser_Testing.py", line 144, in main
        print_cells(parsed_cells)
      File "iwlist_parser_Testing.py", line 123, in print_cells
        print_table(table)
      File "iwlist_parser_Testing.py", line 102, in print_table
        widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic
      File "iwlist_parser_Testing.py", line 102, in <lambda>
        widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic
    TypeError: object of type 'NoneType' has no len()
    Could some pls help me to solve this issue
    Thanks

  • No module named collections

    Hi Experts,
    I've installed TREX 7.0(standalone, win32). I'm trying to enable semantic search by following the document at 'https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f0d3be0e-0401-0010-b780-ff7e4e103ea0'.
    In the step 3., when i try to create a .xtm file using
    "txt2xtm.py --input=
    <TREX_DIR>     opicmapsexampleexample.txt -- output=<TREX_DIR>     opicmapsexampleexample.xtm"
    (in my case, txt2xtm.py --input=C:usrsapTRXTRX00exe     opicmapsexampleexample.txt --output=C:usrsapTRXTRX00exe     opicmapsexampleexample.xtm)
    I get the import error, 'No module named collections'.
    I searched for 'collections.py' file in the entire directory where trex was installed(C:usrsap), but found result is zero.
    It requires to activate the python activation as given in,
    'http://help.sap.com/saphelp_nw04s/helpdata/en/fe/72f11aae4f754d90f44680283a3634/frameset.htm'
    Here, i followed 'Activate the Python extension handler' and in 'Registering the Python extensions' part , I changed "if '0' to '1'" for 'Topic Map' and 'Semantic Search' extensions.
    Here're the commands executed in command prompt,
    C:Documents and SettingsC5119720>cd C:usrsapTRXTRX00
    C:usrsapTRXTRX00>TREXSettings.bat
    C:usrsapTRXTRX00>cd C:usrsapTRXTRX00exeextensionsxtm
    C:usrsapTRXTRX00exeextensionsxtm>txt2xtm.py --input=C:usrsapTRXTRX00exe     opicmapsexampl
    eexample.txt --output=C:usrsapTRXTRX00exe     opicmapsexampleexample.xtm
    Traceback (most recent call last):
      File "C:usrsapTRXTRX00exeextensionsxtm     xt2xtm.py", line 4, in <module>
        from testbase import TestBase, TestError
      File "C:usrsapTRXTRX00exeextensionsxtm     estbase.py", line 2, in <module>
        import os, sys, string, thread, threading, time, fuzzypy
      File "C:usrsapTRXTRX00exePythonlib     hreading.py", line 13, in <module>
        from collections import deque
    ImportError: No module named collections
    C:usrsapTRXTRX00exeextensionsxtm>
    Please suggest how to get this 'collections' module.
    Thanks,
    Arun

    Hi All,
    I got the solution for this. I've been executing the scripts txt2xtm.py without using 'python' keyword. The screenshots given in the document doesn't contain this information and it's relevant for a release lower than 7.0. After adding 'python' keyword before the script name, the error has gone.
    Best Regards,
    Arun

  • No module named csv

    Hi All,
    I'm a newbie to ODI and I'm trying to write a Jython script that manipulates CSV files. I tried to use the csv module of Python and on a Python script it works OK.
    Now I tried to create a procedure with a Jython step but when I try to execute it I get the following error message:
    org.apache.bsf.BSFException: exception from Jython: Traceback (innermost last):
    File "<string>", line 1, in ?
    ImportError: no module named csv
         at org.apache.bsf.engines.jython.JythonEngine.exec(Unknown Source)
         at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    Can I use this Python module in ODI or do I have to write my own CSV handling solution.
    Frank

    Lars, thanks a lot for your reply,
    in the follow, all the informations you wanted.
    You can reproduce this behavior on every 64 bits architecture.
    MaxDB version: 7.6.03.15 (but also on the latest the files are not available, check if you like)
    output of sdbverify:
    an unexpected error occurred
    (btw, I wouldn't like to spend my time to check why this happens. I am sure that the loadercli -p problem is due to the missing files. It is simply a python 'import' problem.)
    output of loadercli -p
    No module named _csv
    ['C:\\Program Files\\sdb\\programs\\lib\\python2.3\\sdb\\loader', 'C:\\Program F
    iles\\sdb\\programs\\lib\\python2.3', 'C:\\Program Files\\sdb\\programs\\pgm\\py
    thon2.3.zip', 'C:\\Program Files\\sdb\\programs\\pgm\\python23.zip', 'C:\\Docume
    nts and Settings\\asadmin\\Desktop', 'C:\\Program Files\\sdb\\programs\\pgm']
    Traceback (most recent call last):
      File "C:\Program Files\sdb\programs\lib\python2.3\sdb\loader\transport.py", li
    ne 2834, in ?
        class TransformationPackage (sax.ContentHandler):
    NameError: name 'sax' is not defined
    Edited by: Ivo Bellin on Oct 14, 2008 4:41 PM

  • Import error: no module named odi

    When i try to do a reverse engineering in planning. it says started when i dadi ok. When i check the operator designer, under start reverse it throws the following error:
    (innermost last):
    File "<string>", line 3, in ?
    ImportError: No module named odi
    at org.apache.bsf.engines.jython.JythonEngine.exec(Unknown Source)
         at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.h.y(h.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    can anyone please help me,
    Thanks in advance,
    Hanson

    You need to edit the PKGBUILD so that it says
    python2 setup.py install --root=$pkgdir/ --optimize=1
    instead of
    python setup.py install --root=$pkgdir/ --optimize=1
    because it uses python2, and python means python3 now (this package has been last updated over a year ago, so I flagged it out-of-date)
    Bad timing ;P http://mailman.archlinux.org/pipermail/ … 23055.html
    Edit: I think you need python2-setuptools or python2-distribute as a dependency instead of 'setuptools' https://aur.archlinux.org/packages.php?ID=43973
    Last edited by karol (2011-12-01 16:17:15)

  • Line 63: No module named _md5

    Hi I get this error when trying to load the bullet.so plugin in maya 2013:
    # Error: file: /usr/autodesk/maya/scripts/startup/bulletInitUI.mel line 29: ImportError: file /usr/autodesk/maya/lib/python26.zip/hashlib.py line 63: No module named _md5
    I have been told in another forum i need to install a version of python with the md5 module.
    I have python2 installed from extra and I installed checksums from AUR, but still same error. When i google I see lots of posts about md5 being depreciated...?
    Any ideas on how so fix this?

    python2 in arch has md5 support, the problem is that maya does silly thing, and havn't really been updated to work with python 2.7
    A workaround would be python 2.6 in virtualenv.
    Last edited by Mr.Elendig (2012-08-16 18:08:47)

  • WLST : ImportError: no module named javaos

    Hi,
    I try to run wlst on a platform linux but at the time I launch wlst I obtain the following error: ImportError: no module named javaos
    my classpath contains wlst.jar,jython.jar, and weblogic.jar, tools.jar, rt.jar, etc.
    pythonpath, pythonhome are set to wlst install directory, and modules, scripts "py".
    thanks in advance.
    here the detail of the exception.
    /pdt/pdslpd1/p/8.1/jdk142_05/bin/java -Dwlst.debug.init=true -Duser.home=/pdt/pdc1pd0/p/mdw/bin/weblogic/ -Dpython.home=/pdt/pdslpd1/p/8.1/wlst/ -Dpython.path=/pdt/pdslpd1/p/8.1/wlst/ weblogic.WLST webloadmin.py
    Initializing WebLogic Scripting Tool (WLST) ...
    Setting the python home to /pdt/pdslpd1/p/8.1/wlst/
    Error executing wlstProfile.py
    Traceback (innermost last):
    File "/pdt/pdc1pd0/p/mdw/bin/weblogic/./wlstProfile.py", line 5, in ?
    ImportError: no module named javaos
    Welcome to WebLogic Server Administration Scripting Shell
    Type help() for help on available commands
    Traceback (innermost last):
    File "webloadmin.py", line 1, in ?
    ImportError: no module named re

    Hi,
    Another subject, Could you explain us how to use specific encoding (for example latin-1) to print european characters in stdout.
    I try to declare sys.setDefaultencoding('latin-1') in wlstProfile.py but it doesn't work fine.
    Thanks.

Maybe you are looking for