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

    Join Date
    May 2004
    Posts
    27
    Rep Power
    0

    Question Py2Exe problem??? Could not find User defined Module and generate Error.


    Helloooooo to all,

    I am really new to python and also to py2exe. I have been working with python since few days. I am trying to create stream.exe file from stream.py file. I am doing this from last three weeks. This is second post for same problem.

    Stream.py file imports module using this syntex
    "from libflow import *"
    and use functions which are defined in libflow module.

    When i used py2exe to create stream.exe ,it creates streams .exe file but atlast gives error message that

    '[libflow]' unable to locate this module.

    When i used stream.exe it is not working properly.

    My setup script, stream.py file and all other necessary files are in same folder.


    What i shoud use to make stream.exe working properly?

    My setup.py file is

    from distutils.core import setup
    import py2exe
    setup(console=["stream.py"])


    Please anybody can send me some referencce or solution example for my problem. Please.............

    Thanks in advance.

    DevHims
  2. #2
  3. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    1: Check and make sure that the module is on the right path
    2: What version of py2exe, and python do you have?

    I hade sorta errors like this.. the location to the modules was incorrect.. so i decided to reinstall everything.. starting from 2.3.2 then whent up to 2.3.4 installed py2exe and never got another error while wrapping my programs in to executable files

    Also running your program out of the python directory on windows.. can sometimes cause this error as well ( weird but its true )
  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Did the program run without using py2exe?

    Where did you install the libflow module? It is not part of the standard distribution.

    Grim
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Posts
    27
    Rep Power
    0

    Thumbs down


    Hey xlodrt,

    I am using py2exe 0.5.0 and python 2.3. I checked path using "Sys.path" . All paths are listed there. And my Module also in one the directory from that list. So, i guess it should work. What do u think?

    @ Grim,

    Program is working fine. The module "libflow" is developed by me. It is not standard module come with python. Scripts which uses this module,it is working fine. But when i tried to convert one my script into .exe which uses this module, it
    gives error.

    I think i will try with python 2.3.4 now. Hopefully it will work. But please provide me your inputs, if you find any soultion.

    Thanks Buddys.

    DevHims
  8. #5
  9. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    Usualy when you create a python module you put it inside site-package, have you tried that? ( i mean the module itself ) i know you can add a directory with your module inside.. but i dont know how to do that part yet
  10. #6
  11. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    To create directories or "packages" is very easy like this:

    1. Create a sub-directory called "mypackage".
    2. Create a file in that directory called __init__.py (it can be empty but you could put a comment in it.)
    3. Put your files in that directory e.g. file1.py, file2.py

    This sub-directory can be placed in the working directory for the application or somewhere (site-packages) in the $PYTHONPATH.

    when you want to import file1 or file 2 you use:

    import mypackage.file1
    import mypackage.file2

    The important thing is to always have the __init__.py file. This tells python that the subdirectory is valid for searching.
    __init__.py is also a real python module and is executed automatically (a bit like a class __init__ method ). There are a number of useful things you can do with __init__.py so it worth reading up on.

    grim

IMN logo majestic logo threadwatch logo seochat tools logo