Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Jason Raff <jraff@ce...> - 2008-08-21 19:06:44
Attachments:
Message as HTML
|
Hi All, I also posted a similar question to the python usenet group, but I so far haven't gotten any response. I've just had no luck finding as answer to this, but it seems like this would be something done fairly commonly. Using python 2.4, I've created a testing application. When the app starts up, I do a "from tests import *" and it looks at the /tests directory and loads up all the tests it finds at that time. This works fine when interpreting the python code directly. The problem I'm having is trying to create an executable for distribution. What I'd like to be able to do is to include everything in the library.zip *except* the tests directory and then as I (or whoever) creates more and more tests, have the ability to simply drop them into the directory and the next time the app starts, it'll pick them up. However, if I don't include the tests in library.zip, then when I hit the "from tests import *", it complains "AttributeError: 'module' object has no attribute 'test1'" when it gets to the first test. And If I do include the tests in the library.zip, it works with the tests that I have now, but then I still can't add any new ones without the attribute error unless I regenerate the exe every time. Basically, it seems like it comes down to importing a package outside the library.zip. So, is there any way to do this with py2exe? Or even another exe creating application? Thanks, Jason |
From: Alexander Belchenko <bialix@uk...> - 2008-08-21 19:52:21
|
http://docs.python.org/tut/node8.html#SECTION008430000000000000000 |
From: Jason Raff <jraff@ce...> - 2008-08-21 21:12:31
|
Hi, Can you give me more info? I mean, I've tried explicitly adding the path to the package in my main py file via "sys.path.append(__path__[0] + '\\tests')". But this does not seem to help. Thanks, Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Alexander Belchenko Sent: Thursday, August 21, 2008 3:54 PM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip http://docs.python.org/tut/node8.html#SECTION008430000000000000000 ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users |
From: Jason Raff <jraff@ce...> - 2008-08-22 14:46:51
|
Hi Again, So, someone responded with some tips about paths, so my paths are correct in the exe and I verified this by printing them out. So, my problem is not that, I guess. And in my original email, I simplified my scenario because I thought it was a problem with paths. So, let me back up a little. My tests directory actually has several sub-directories, so it's laid out like this: tests/testCategory1, tests/testCategory2, tests/testCategory1/subCategory1/test1, and so on. With potentially hundreds of tests, I needed some organization. Anyway, in my tests directory, I have an __init__.py with " __all__=["testCategory1", "testCategory2"]" and it's this that the exe keeps choking on. Even though I append the path directly above the __all__ via " sys.path.append(os.path.abspath('') + '\\tests')" and "sys.path.append(os.path.abspath('') + '\\tests\\testCategory1')" (the second one just to be safe), when I execute the import *, it still tells me "AttributeError: 'module' object has no attribute 'testCategory1'" Again, this works fine when just executing the python code without the exe. What am I doing wrong? Or can anyone even point me to the right place to possibly find an answer? Thanks, Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Jason Raff Sent: Thursday, August 21, 2008 5:13 PM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip Hi, Can you give me more info? I mean, I've tried explicitly adding the path to the package in my main py file via "sys.path.append(__path__[0] + '\\tests')". But this does not seem to help. Thanks, Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Alexander Belchenko Sent: Thursday, August 21, 2008 3:54 PM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip http://docs.python.org/tut/node8.html#SECTION008430000000000000000 ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users |
From: Jason Raff <jraff@ce...> - 2008-08-26 17:43:40
|
No one? Can anyone at least point me in the right direction? Or where I might be able to go to get some answers for this? Thanks, Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Jason Raff Sent: Friday, August 22, 2008 10:47 AM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip Hi Again, So, someone responded with some tips about paths, so my paths are correct in the exe and I verified this by printing them out. So, my problem is not that, I guess. And in my original email, I simplified my scenario because I thought it was a problem with paths. So, let me back up a little. My tests directory actually has several sub-directories, so it's laid out like this: tests/testCategory1, tests/testCategory2, tests/testCategory1/subCategory1/test1, and so on. With potentially hundreds of tests, I needed some organization. Anyway, in my tests directory, I have an __init__.py with " __all__=["testCategory1", "testCategory2"]" and it's this that the exe keeps choking on. Even though I append the path directly above the __all__ via " sys.path.append(os.path.abspath('') + '\\tests')" and "sys.path.append(os.path.abspath('') + '\\tests\\testCategory1')" (the second one just to be safe), when I execute the import *, it still tells me "AttributeError: 'module' object has no attribute 'testCategory1'" Again, this works fine when just executing the python code without the exe. What am I doing wrong? Or can anyone even point me to the right place to possibly find an answer? Thanks, Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Jason Raff Sent: Thursday, August 21, 2008 5:13 PM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip Hi, Can you give me more info? I mean, I've tried explicitly adding the path to the package in my main py file via "sys.path.append(__path__[0] + '\\tests')". But this does not seem to help. Thanks, Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Alexander Belchenko Sent: Thursday, August 21, 2008 3:54 PM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip http://docs.python.org/tut/node8.html#SECTION008430000000000000000 ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users |
From: Tim van der Leeuw <tnleeuw@gm...> - 2008-08-26 18:53:08
Attachments:
Message as HTML
|
Hi Jason, On Tue, Aug 26, 2008 at 7:43 PM, Jason Raff <jraff@...> wrote: > No one? Can anyone at least point me in the right direction? Or where > I might be able to go to get some answers for this? > > Thanks, > Jason > I tried already to point you in the right direction, but apparently that didn't work for you. So now I don't really know. If you add "C:/TEMP" to your sys.path, put there a python file, and try to import it? Does that work? (To just begin with simple things). Can you perhaps show us the value which you're adding to sys.path, just for everyone to double-triple-check that what you're adding is correct? Can you perhaps make a standalone sample consisting of 1 Python file with 'program', 1 Python file that needs to be imported, 1 Setup.py to make the executable? Then put the 'module' Python file in a fixed location (such as "C:/TEMP", but anything goes) and add that fixed location to your sys.path. Then test and if it still fails as EXE, there'll be a standalone testcase to check. Regards, --Tim |
From: Daniel Pryden <daniel@pr...> - 2008-08-26 19:13:51
|
I think your problem is the "from package import *". I would try using an __init__.py that imports all your sub-modules, or else just write some code to import modules manually. For a previous project, I wrote code to find .py files in a directory and import classes from them as a "plugin" system for a frozen app (on Linux so not using py2exe), but I don't think I can distribute the code. But that does seem like the right approach for what you're trying to do. The trick is just some clever use of the __import__ function (see the Python docs for details) plus some run-time introspection of objects. - Daniel. Jason Raff wrote: > No one? Can anyone at least point me in the right direction? Or where > I might be able to go to get some answers for this? > > Thanks, > Jason > > -----Original Message----- > From: py2exe-users-bounces@... > [mailto:py2exe-users-bounces@...] On Behalf Of Jason > Raff > Sent: Friday, August 22, 2008 10:47 AM > To: py2exe-users@... > Subject: Re: [Py2exe-users] Importing a package not included in > library.zip > > Hi Again, > So, someone responded with some tips about paths, so my paths are > correct in the exe and I verified this by printing them out. So, my > problem is not that, I guess. And in my original email, I simplified my > scenario because I thought it was a problem with paths. So, let me back > up a little. > > My tests directory actually has several sub-directories, so it's laid > out like this: tests/testCategory1, tests/testCategory2, > tests/testCategory1/subCategory1/test1, and so on. With potentially > hundreds of tests, I needed some organization. Anyway, in my tests > directory, I have an __init__.py with " __all__=["testCategory1", > "testCategory2"]" and it's this that the exe keeps choking on. Even > though I append the path directly above the __all__ via " > sys.path.append(os.path.abspath('') + '\\tests')" and > "sys.path.append(os.path.abspath('') + '\\tests\\testCategory1')" (the > second one just to be safe), when I execute the import *, it still tells > me "AttributeError: 'module' object has no attribute 'testCategory1'" > > Again, this works fine when just executing the python code without the > exe. What am I doing wrong? Or can anyone even point me to the right > place to possibly find an answer? > > Thanks, > Jason > > -----Original Message----- > From: py2exe-users-bounces@... > [mailto:py2exe-users-bounces@...] On Behalf Of Jason > Raff > Sent: Thursday, August 21, 2008 5:13 PM > To: py2exe-users@... > Subject: Re: [Py2exe-users] Importing a package not included in > library.zip > > Hi, > Can you give me more info? I mean, I've tried explicitly adding the > path to the package in my main py file via "sys.path.append(__path__[0] > + '\\tests')". But this does not seem to help. > > Thanks, > Jason > > -----Original Message----- > From: py2exe-users-bounces@... > [mailto:py2exe-users-bounces@...] On Behalf Of > Alexander Belchenko > Sent: Thursday, August 21, 2008 3:54 PM > To: py2exe-users@... > Subject: Re: [Py2exe-users] Importing a package not included in > library.zip > > http://docs.python.org/tut/node8.html#SECTION008430000000000000000 > > > ------------------------------------------------------------------------ > - > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Py2exe-users mailing list > Py2exe-users@... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------ > - > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Py2exe-users mailing list > Py2exe-users@... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------ > - > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Py2exe-users mailing list > Py2exe-users@... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ |
From: Jason Raff <jraff@ce...> - 2008-09-02 18:43:19
|
Just to let you all know, I finally got this working via finding the directories and files and then manually importing via some run-time introspection of objects. So, I guess py2exe just does not like "from package import *" if it's not in the library.zip. The only problem now is that the importing seems somewhat slower, but at least it does what I want now. Thanks for all your help. Jason -----Original Message----- From: py2exe-users-bounces@... [mailto:py2exe-users-bounces@...] On Behalf Of Daniel Pryden Sent: Tuesday, August 26, 2008 3:15 PM To: py2exe-users@... Subject: Re: [Py2exe-users] Importing a package not included in library.zip I think your problem is the "from package import *". I would try using an __init__.py that imports all your sub-modules, or else just write some code to import modules manually. For a previous project, I wrote code to find .py files in a directory and import classes from them as a "plugin" system for a frozen app (on Linux so not using py2exe), but I don't think I can distribute the code. But that does seem like the right approach for what you're trying to do. The trick is just some clever use of the __import__ function (see the Python docs for details) plus some run-time introspection of objects. - Daniel. Jason Raff wrote: > No one? Can anyone at least point me in the right direction? Or where > I might be able to go to get some answers for this? > > Thanks, > Jason > > -----Original Message----- > From: py2exe-users-bounces@... > [mailto:py2exe-users-bounces@...] On Behalf Of Jason > Raff > Sent: Friday, August 22, 2008 10:47 AM > To: py2exe-users@... > Subject: Re: [Py2exe-users] Importing a package not included in > library.zip > > Hi Again, > So, someone responded with some tips about paths, so my paths are > correct in the exe and I verified this by printing them out. So, my > problem is not that, I guess. And in my original email, I simplified my > scenario because I thought it was a problem with paths. So, let me back > up a little. > > My tests directory actually has several sub-directories, so it's laid > out like this: tests/testCategory1, tests/testCategory2, > tests/testCategory1/subCategory1/test1, and so on. With potentially > hundreds of tests, I needed some organization. Anyway, in my tests > directory, I have an __init__.py with " __all__=["testCategory1", > "testCategory2"]" and it's this that the exe keeps choking on. Even > though I append the path directly above the __all__ via " > sys.path.append(os.path.abspath('') + '\\tests')" and > "sys.path.append(os.path.abspath('') + '\\tests\\testCategory1')" (the > second one just to be safe), when I execute the import *, it still tells > me "AttributeError: 'module' object has no attribute 'testCategory1'" > > Again, this works fine when just executing the python code without the > exe. What am I doing wrong? Or can anyone even point me to the right > place to possibly find an answer? > > Thanks, > Jason > > -----Original Message----- > From: py2exe-users-bounces@... > [mailto:py2exe-users-bounces@...] On Behalf Of Jason > Raff > Sent: Thursday, August 21, 2008 5:13 PM > To: py2exe-users@... > Subject: Re: [Py2exe-users] Importing a package not included in > library.zip > > Hi, > Can you give me more info? I mean, I've tried explicitly adding the > path to the package in my main py file via "sys.path.append(__path__[0] > + '\\tests')". But this does not seem to help. > > Thanks, > Jason > > -----Original Message----- > From: py2exe-users-bounces@... > [mailto:py2exe-users-bounces@...] On Behalf Of > Alexander Belchenko > Sent: Thursday, August 21, 2008 3:54 PM > To: py2exe-users@... > Subject: Re: [Py2exe-users] Importing a package not included in > library.zip > > http://docs.python.org/tut/node8.html#SECTION008430000000000000000 > > > ------------------------------------------------------------------------ > - > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Py2exe-users mailing list > Py2exe-users@... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------ > - > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Py2exe-users mailing list > Py2exe-users@... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------ > - > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Py2exe-users mailing list > Py2exe-users@... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------ - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ ------------------------------------------------------------------------ - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Py2exe-users mailing list Py2exe-users@... https://lists.sourceforge.net/lists/listinfo/py2exe-users |