Need help with Python

Discussion in 'Mac Programming' started by CP123, Aug 16, 2009.

  1. CP123 macrumors regular

    Joined:
    Dec 22, 2008
    #1
    Hello all, I just bought a book on Python, and started to go through it (bought it for my children and myself). I'm having a problem importing 'easygui'.

    I downloaded easygui to the following:/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/

    When I go in Finder, I see a easygui83 file, that has the easygui in it.

    When I type: import easygui in IDLE I get the following messages:

    Traceback (most recent call last):
    File "<pyshell#0>", line 1, in <module>
    import easygui
    ImportError: No module named easygui

    What am I doing wrong? Is the easygui file in the wrong place?
     
  2. Cinder6 macrumors 6502

    Cinder6

    Joined:
    Jul 9, 2009
    #2
    I've never used easygui, but you may have to use an installer, not just drop it into a directory. Is there a file called setup.py in the module's directory? If so, try running 'python setup.py install'.
     
  3. CP123 thread starter macrumors regular

    Joined:
    Dec 22, 2008
    #3
    There is no file called 'setup.py'

    When I try to import easygui from SPE, I get the message that the module is not found.
     
  4. Jedi128 macrumors 6502

    Joined:
    Jul 7, 2005
    Location:
    New York, NY
    #4
    You said that the file name is easygui83? This means that the module you want to import the class from has that name. In order for the python console to see the class "easygui" you must import the module "easygui83". Or to get to the point more quickly you can type: "from easygui83 import easygui"

    Or typing: "import easygui83" then "import easygui" should also work.

    If neither of these methods work then it could be that the site packages directory is not in the sys.path collection. Let us know if what I said fixes your problem though.
     
  5. CP123 thread starter macrumors regular

    Joined:
    Dec 22, 2008
    #5
    I'm getting: Import error. No module named easygui83.

    easygui83 is a folder in site packages. easygui.py is located in easygui83. I keep getting module not found.
     
  6. CP123 thread starter macrumors regular

    Joined:
    Dec 22, 2008
    #6
    I figured it out. easygui.py has to be in the site-packages folder. Once you download easygui, it creates a folder called easygui83, which has easygui.py in it. You have to take easygui.py out of that folder and put it directly in site-packages.

    Now it works.

    Thank you everyone for your responses.
     

Share This Page