#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Bimingham,AL
    Posts
    68
    Rep Power
    11

    import error on linux


    I have the following line in my code:-
    except wx._core.PyAssertionError

    it runs fine on my windows machine but when i try to run it on linux box it says module doesnt have _core .
    But runs fine when i change _core to core.

    Any idea why???
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    I can't check wx at the moment so these are general comments...

    Your code calling
    wx._core.....
    does not sound portable. _ is mostly used to indicate a private attribute or method (in this case a private module) to be used by the package only so almost by definition it is not guaranteed to be available for external access across platforms.

    Perhaps it would be best to raise your own exception or use a higher level interface in a publicly accessible module?

    Are the versions of wxPython the same on each platform? I know there have to been many features/changes introduced between releases.

    grim
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    27
    Rep Power
    0
    Originally Posted by wx_uab
    I have the following line in my code:-
    except wx._core.PyAssertionError

    it runs fine on my windows machine but when i try to run it on linux box it says module doesnt have _core .
    But runs fine when i change _core to core.

    Any idea why???
    In wxPython under windows, there are 2 core's you could be referring to. The plain wx.core is a .py file that was generated using SWIG to provide an interface to the OTHER core: wx._core. wx._core is a .pyd file. In the windows install, the core.py and the _core.pyd are placed in the same directory (\site-packages\wx) by default. So this should shed some light on what you are referring to when you say "wx._core" vs. "wx.core" in windows.

    Unfortunately, I haven't used wxPython under Linux yet, so I can't tell you for certain what is happening with the core.py file and the _core.pyd files. But you can check that out for yourself.

    All that said, I would suggest simply using "wx.core.PyAssertionError". This works under windows, and apparently works for you under linux. There is no reason you should need to access wx._core vs. wx.core unless you were really sure of what you were doing. Hence the "_" as Grim mentioned.

    Derrick
    Last edited by p4j; August 31st, 2004 at 11:56 AM. Reason: minor changes

IMN logo majestic logo threadwatch logo seochat tools logo