ImportError: No module named exceptions

9 thoughts on “ImportError: No module named exceptions

  1. I’m trying to execute Python scrypt (28k py or 13k pyo size) and I use modules:

    import MDM
    import MDM2
    import SER
    import MOD
    import sys



    Everything is OK when is script executing on PC (PythonWin 1.5.2+) but on GM862 doesn’t work.


    I’m using Telit CMUX and Python debug send me something like this:

    — Killing tasks… —
     SY ERROR ON QUEUE  Nucleus error code -46


    ‘import exceptions’ failed; traceback:
    ImportError: No module named exceptions
    Warning!  Falling back to string-based exceptions
    Python 1.5.2+ (#0, Jan 24 2008, 14:55:00) [C] on GM862 GPS PYTHON

    Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam



    1. Ignore exceptions failures, nothing important there. Try first with a
      simple "hello" script to check your procedures are good, then proceed
      with something more complicated.

      1. Cosmin or enyone else, I will show to you my .py if you are interested
        in debugging that script. I  would very appreciate for any help.

        1. I see you are making some math calculations, note float is not supported by module Python implementation.

          In slightly other note, you are doing too much math in your script, I suggest to do the minimum parsing here and leave the power stuff to the server application, of course if is possible – but should be in almost any case. For example if you are trying to geo-fence, you can simply upload the location to the server and receive back the answer, in or out. Balance the bigger data traffic volume and more battery consumption with the module’s math and speed capabilities and do the best.







          1. Thank you for answare.

            Im not using any float variables.

            All math functions are working well on privious version of my script.

            I  suspect about string based operations:

                            LocalDate = ”
                            UTCgod = ’20’ + UTCgod
                            LocalDate = UTCgod + ‘-‘
                            LocalDate = LocalDate + UTCmjes
                            LocalDate = LocalDate + ‘-‘
                            LocalDate = LocalDate + UTCdan
                            print ‘LocalDate = ‘, LocalDate
                            LocalVrijeme = LocalDate + ‘-‘
                            LocalVrijeme = LocalVrijeme + LocalTime
                            print ‘LocalVrijeme = ‘, LocalVrijeme


             and second “while” loop:

                            while index_slanja < len_index_slanja:
                                red_za_slanje = bafer_slanje[index_slanja]
                                a = MDM.send(red_za_slanje,1) 
                                a = MDM.send(‘rnHost: gps.lukas-computers.comrnrn’,1)
                                a = SER.send(red_za_slanje)
                                a = SER.send(‘rnHost: gps.lukas-computers.comrnrn’)
                                index_slanja = index_slanja + 1


            Before this changes in script it was all OK.

          2. Working well where, on module or PC? You have many division operations there.


            See below for some suggestions:


            Why do I get "RuntimeError: Bad code object in .pyc file" ?
            3 causes were observed:
            should be file extension related to files imported in the main script
            (or in other scripts) and compiled by the PythonWin tool while you run
            the main script. But you shouldn’t download these pyc files to the
            On the module you should have just pyo files.
            so the
            procedure should be :
            1- delete all the files (*.py, *pyc or
            *pyo) you have at present on the module
            2- compile (don’t  run the
            main py file)  every py file of the project 
            on PC (if you have
            installed the PythonWin tool: select each py file, compile option with
            click on the right key of the mouse), obtaining a correspondent pyo file
            all the pyo files on the module
            4-enable the main pyo file and
            run the main on the module  with one of the methods (you could try for
            test with at#execscr).

            II –
            if you use
            hyperterminal and at#write to download, for some pyo file you
            will have the bad behavior you have described. This doesn’t happen with
            other kind of terminal emulator (e.g. Procomm) and also it doesnt’
            happen with Download option of PythonWin as you noted. This is because,
            for unknown reason, hyperterminal adds for some particular files a hex char after 0D

            III –
            you could have a some kind of corrupted NVM with the previous operations
            Upgrade or re-install the firmware and donwload on the module the same pyos



          3. Privious scripts .py working well directly on GM862 and on PythonWin.


            About suggestions:


            I will try download script from  PythonWin direct. 

            I am already update firmware to latest and I working on 3 diferent GM862 and they all have the same behavior. 

  2. Meny of my smaller scripts work fine.  

    When I compile my sript to pyc file and run on GM862 I got error:


    RuntimeError: Bad code object in .pyc file
    # clear __builtin__._
    # clear sys.path
    # clear sys.argv
    # clear sys.ps1
    # clear sys.ps2
    # clear sys.exitfunc
    # clear sys.exc_type
    # clear sys.exc_value
    # clear sys.exc_traceback
    # clear sys.last_type
    # clear sys.last_value
    # clear sys.last_traceback
    # restore sys.stdin
    # restore sys.stdout
    # restore sys.stderr
    # cleanup __main__
    # cleanup sys
    # cleanup __builtin__
    # cleanup ints: 1 unfreed int in 1 out of 1 block

  3. I solve may problem with Python script. The reason was in Hyper Terminal wrong sending file to Telit module. I try  WinPython and I see  my script is working after one month of inefficient Attempts. I have no words to thank you Cosmin.