Some odd py2exe troubles

Tubez

09-08-2006 20:15:33

Hey everyone!

I finally managed to create something that i found worth showing to a few friends, so i set out to make a stand-alone distribution that I could mail off and/or post on a website. After a bit of monkeying around with DLLs and things like that I managed to get py2exe to run through the whole process without complaining.
Funnily enough it worked at step 5 of http://www.ogre3d.org/wiki/index.php/PyOgreExecutable, and i didnt need 6 and 7 to have it run locally. (EDIT: I got most of the DLLs of step 7 in the "monkeying around" bit above. The .cfg files were already copied as I consider them application assets, not a part of pyogre. I do not seem to have any .pkg files in the specified directories though.)

It also works when run out of a different directory than the one it was built in (by just e.g. moving /dist to the desktop and running there.)

The real fun came when I copied the /dist directory and tried to run it on a machine without python installed:


Traceback (most recent call last):
File "pathman.py", line 2, in ?
File "pyogre\ogre.pyc", line 4, in ?
File "pyogre\_ogre.pyc", line 9, in ?
File "pyogre\_ogre.pyc", line 7, in __load
ImportError: DLL load failed: This application has failed to start because the a
pplication configuration is incorrect. Reinstalling the application may fix this
problem.


Note that it does not say what DLL was not loaded. Pokign around in pyogre\ogre.py revealed nothing interesting at the specified lines, and certainly no __load statement. Running sysinternals' "filemon" revealed tons of disk activity, but nothing that I could easily identify as wrong. Python looks for files all over the place, and it's common to see "NOT FOUND" results in there anyway.

So... does anyoen ahve any bright ideas?

Tubez

10-08-2006 14:25:19

Addendum:

line 4 in ogre.py is:

import _ogre

And the only _ogre in the site-libs directory is _ogre.pyd.

However in the dist directory there is also a library.zip/pyogre/_pyogre.pyc. The error message suggests this is the one getting loaded. I have no idea what .py was used to generate the .pyc or even why it's there in the first place. I suppose it is possible that it really wants to import the .pyd instead and the .pyc is in the way.
Removing the .pyc however results in:


Traceback (most recent call last):
File "pathman.py", line 2, in ?
File "pyogre\ogre.pyc", line 4, in ?
ImportError: No module named _ogre


Despite the fact that the .pyd is sitting nicely in /dist.
Adding the .pyd to the zip where the .pyc resided does not change this matter.

Importing the pyd directly works:

Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ogre
>>> _ogre
<module '_ogre' from '_ogre.pyd'>
>>>


Can anyone help me figure out what is wrong here?

viblo2

10-08-2006 14:51:21

I haven't py2exed anything with pyogre1.2 yet, but in an old project I had this filestructure:

mygame/dlls (This is the map where the .exe is):

bz2.pyd
cg.dll
devil.dll
fmod.dll
GameApplication.exe
GameApplication.exe.log
highscores.dat
ilu.dll
ilut.dll
library.zip
MSVCR71.dll
ogre.cfg
Ogre.log
OgreGUIRenderer.dll
OgreMain.dll
OgrePlatform.dll
Plugin_BSPSceneManager.dll
Plugin_CgProgramManager.dll
Plugin_OctreeSceneManager.dll
Plugin_ParticleFX.dll
pySonic.pyd
python24.dll
ReferenceAppLayer.dll
RenderSystem_Direct3D7.dll
RenderSystem_Direct3D9.dll
RenderSystem_GL.dll
unicodedata.pyd
w9xpopen.exe
xerces-c_2_5_0.dll
zlib.pyd
zlib1.dll
_imaging.pyd
_ogre.pyd
_psyco.pyd


in library.zip:
a long list of pyc-files, i.e. DataManager.pyc and random.pyc. And also a couple of folders:
in library.zip/pyogre:
__init__.pyc, _ogre.pyc and ogre.pyc
in library.zip/Actors:
game related files, in this case Actors.

Tubez

10-08-2006 15:28:38

Nothing looks strikinglyout of place, all the key files seem to be where they are in my distribution. The exception is of course the dlls etc for modules that I'm not using.
Did you test it on machines without python/ogre installed as well?
I might downgrade to 1.0 and see if it changes anything.
Did you do anything special in your setup.py?

PS: Could a moderator please delete the two redundant posts above? I was having some networks issues, and i guess i reloaded the wrong page a few times.

dermont

11-08-2006 05:20:29

Just tried following the steps on the wiki for py2exe. Setup.py was as per the wiki. The exe runs fine on another computer without python/ogre.

Looks like you may be missing some DLLs perhaps the VC8 redist(?). Try downloading dpendency walker and opening OgreMain.dll on your machine that doesn't have python/ogre installed. That should let you see which DLLs are missing.

http://www.dependencywalker.com/

dirkk

11-08-2006 16:55:24

I can confirm that it works here, but I had to add "msvcp80.dll" and "msvcr80.dll" to the directory first.

Tubez

11-08-2006 23:04:14

Note to self, so i can find back the link.

Seems to be related to this:

http://channel9.msdn.com/ShowPost.aspx?PostID=23261

Will post results as soon as I have had time to investigate further.


EDIT:

Allright, reinstalling the vcredist.exe did the trick.
Apparently the original XP shipped with a different version of the runtime library dlls, and if you update the dlls without updating the metadata (manifest) all hell breaks loose.

My sincere gratitude goes out to everyone who pointed me in the right direction. Especially the tip to try and use dependencywalker proved to be a hit, as it enabled me to see error messages that were not printed to stdout. Not to mention the fact that it's a lot easier to use for these things than filemon :P

You guys rock!