473,805 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

py2exe importing a package not in library.zip

Hi,
I'm sorry if this has been asked before, but I can't seem to find an
answer to this anywhere and so far, trial and error hasn't gotten me
far either.

Using python 2.4, I've created a testing application. When the app
starts up, I do a
Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. 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,
MyPetSlug
Aug 20 '08 #1
1 1545
On Aug 20, 4:48*pm, mypets...@gmail .com wrote:
Hi,
I'm sorry if this has been asked before, but I can't seem to find an
answer to this anywhere and so far, trial and error hasn't gotten me
far either.

Using python 2.4, I've created a testing application. *When the app
starts up, I do a
Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. 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,MyPetSlu g
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" ,
"testCatego ry2"]" 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.abspat h('') + '\\tests')" and
"sys.path.appen d(os.path.abspa th('') + '\\tests\\testC ategory1')" (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,
MyPetSlug
Aug 25 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17737
by: x-herbert | last post by:
Hi, I have a small test to "compile" al litle script as a WMI-Tester. The script include a wmi-wrapper and "insert" the Win32-modeles. here the code: my "WMI-Tester.py" ----- import wmi
5
4024
by: Rene Olsthoorn | last post by:
Dear readers, py2exe has a problem including libxml2. Not at building time, but at runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has the problem? (and can you drop me your setup.py scipt, please). Thanks in advance, Rene O.
3
3033
by: Larry Bates | last post by:
I had occasion to look back at a project I did over a year ago and needed to make one small change. I use py2exe to package it for distribution via Inno Setup. After making my change I tried to run my setup script that worked fine before and get the following message: F:\SYSCON\WTS\HTMLmenu>python HTMLmenuSetup.py py2exe -w running py2exe running build running build_scripts
0
1534
by: Jimmy Retzlaff | last post by:
py2exe 0.6.4 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.4:
0
1522
by: Jimmy Retzlaff | last post by:
py2exe 0.6.5 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.5:
1
2992
by: Jimmy Retzlaff | last post by:
py2exe 0.6.8 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.8:
0
1533
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
3
4445
by: MyPetSlug | last post by:
Hello Guys, Using Pythong 2.4 and py2exe 0.6.6. So, I've created a wxPython application that I use for testing. The idea is to have a tests directory so that every time the application starts, it looks in the directory and loads the tests it sees into a list it uses during runtime. So, I've got this working fine on my machine locally, but now I'm trying to get it working right with py2exe. My problem is, if I include my 'tests" package in...
0
3124
by: Jimmy Retzlaff | last post by:
py2exe 0.6.9 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.9:
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.