How do I compile a game built in panda3d version 1.10.0? (Solved)

Hmm… as you say, the code looks fine at first glance. In which case I really would like to see your directory structure (that of your installed/unzipped distributable version, specifically), as that’s my best guess as to what’s going wrong. Would you mind uploading screenshots of said directory structure, please? (You should be able to upload them directly to the forum, I think.)

I’ll confess that I didn’t know about using “with”–thank you for mentioning that!

oh sorry I left for a while here is the snapshot of the file.

Hmm… I take it that the executable is in “dist/Vortex The Pretty Alpha Version 1/Vortex The Pretty Alpha Version 1”? If so, then the file seems to be in “Contents/Resources/room/”, rather than just in “room/”, relative to the executable.

yeah, well, the thing is, I tried moving it there with the in the MacOS folder with the executable but it still did not work. is it possible that the os python module was not packed in with the package?

Edit: oh, you mean the executable location? it is located in the MacOs folder near the resources folder.

To check: Did you move the file into the same folder as the executable, or into a folder with the path “room/” relative to the executable? That is, did you have a subdirectory of the executable’s folder named “room”, with the text-file in there?

What the code seems to be expecting is a structure like this:

    <Your executable's directory>/
       |
       |__Room/
            |
            |____room1.txt

I’ll try moving the executable in the resources folder, give me a minute.

Edit: no did nothing, and already tried the reverse yesterday.

Did you check that you were getting the same error? Just moving the executable might cause other problems, as it might struggle to find other files…

yep, I used terminal to reveal the error messages, here the error below.

Last login: Fri May 31 17:49:18 on console
MyName-Air:~ MyName$ /Users/MyName/Desktop/dist/Vortex\ The\ Pretty\ Alpha\ Version\ 1/Vortex\ The\ Pretty\ Alpha\ Version\ 1.app/Contents/Resources/Vortex\ The\ Pretty\ Alpha\ Version\ 1
Warning: pandac.PandaModules is deprecated, import from panda3d.core instead
Known pipe types:
CocoaGraphicsPipe
(all display modules loaded.)
:audio(error): load_dso(libp3fmod_audio.so) failed, will use NullAudioManager
:audio(error): No error.
Traceback (most recent call last):
File “Main.py”, line 11982, in load
FileNotFoundError: [Errno 2] No such file or directory: ‘room/room1.txt’
:task(error): Exception occurred in PythonTask TXTLoader
Traceback (most recent call last):
File “Main.py”, line 13875, in
File “/Users/MyName/Desktop/VTP_ALPHA_v1/build/whl_cache/panda3d-1.10.3+opt-cp36-cp36m-macosx_10_6_x86_64.whl/direct/showbase/ShowBase.py”, line 3121, in run
File “/Users/MyName/Desktop/VTP_ALPHA_v1/build/whl_cache/panda3d-1.10.3+opt-cp36-cp36m-macosx_10_6_x86_64.whl/direct/task/Task.py”, line 531, in run
File “/Users/MyName/Desktop/VTP_ALPHA_v1/build/whl_cache/panda3d-1.10.3+opt-cp36-cp36m-macosx_10_6_x86_64.whl/direct/task/Task.py”, line 485, in step
File “Main.py”, line 11982, in load
FileNotFoundError: [Errno 2] No such file or directory: ‘room/room1.txt’
MyName-Air:~ MyName$

Hmm… Odd.

This may be a result of moving things about, but I do notice that, if I’m inferring correctly, the first line seems to indicate that your executable is in a sub-folder of “Resources”, one which, based on your screenshot, sits alongside the “Room” folder. Something like this:

  Vortex The Pretty Alpha Version 1
    |
    |___ Resources
           |
           |____ Vortex The Pretty Alpha Version 1
           |       |
           |       |____<Your executable>
           |
           |____room
                   |
                   |____room1.txt
    

Instead of something like this:

  Vortex The Pretty Alpha Version 1
    |
    |___ Resources
           |
           |____ Vortex The Pretty Alpha Version 1
                   |
                   |____<Your executable>
                   |
                   |____room
                         |
                         |____room1.txt
    

If I’m misunderstanding, then my apologies! I fear that it can be tricky to figure these things out remotely. ^^;

No worries. it’s more like

|
|___ Vortex The Pretty Alpha Version 1 (App wrapper/package)
       |
       |____ Contents
                |
                |   
                Resources
                                |
                                |<Your executable
                                |
                                |____room
                                                |
                                                |____room1.txt

Your diagram broke, I fear–what I find to work is to use code-tags (three ` characters at the start, and another three at the end), set to render as plain-text. Like this:

```text
<text-diagram here>
```

Ah, much better! Thank you. :slight_smile:

Hum… But that does indeed look correct to me. :/

In that case I really don’t know, I’m afraid–perhaps it’s something Mac-specific (I don’t really use that platform). Hopefully someone else will have a better idea! :/

I tired (laughs), but yeah, do you think a python module may be not included, I was reading online that “os” python module handles portable pathways, I use the “os” module, but I don’t know if it is included with the executable.

there is a “include_modules” feature for the setup.py, but I could not find a good enough syntax example to test it.

I’ve used os before, and I think that I’ve had it working without explicitly including the module via “include_modules”.

But again, it’s possible that something is different on Mac.

Hmm… To be on the safe side, it might be worth trying Panda’s version of the “os” module, if you’re not doing so already. Perhaps it handles something on Mac better than does the standard Python version? See the following page, under “Thread-safe file I/O”: http://www.panda3d.org/manual/?title=File_Reading

okay, I so I commented “import os” out then added the panda import from the article you gave me, and no, still the same, sorry for the long wait I had to rebuild from the python script.

The wait isn’t a problem, don’t worry. :slight_smile:

As to the Panda version of “os”, ah well, that was a long shot anyway. Once again I step back, hoping that someone else will have some insight. :/

maybe it is something wrong with the wrapper, I,m going to keep testing, thank you for your help.

Things have made a interesting turn, after my conversation with Thaumaturge, it lead me to look into the “os” module some more and I found a alternative way to use “open”

txt = open(str(os.path.dirname(os.path.abspath(‘file’)))+‘/room/room’+str(room)+‘.txt’)

I have stumbled upon “os.path.dirname(os.path.abspath(‘file’))” what this does is print out the location of the script that is running! useful, so what I did was include this to the “open” to find the exact path, again I got the same error but a little different this time.

This time it said the file missing from ‘/Users/MyName/room/room1.txt’ do you see that? it is looking in the account’s root directory! what? that is no where near the desktop (where the app package resides) or in the resources folder of the app package.

Is this a flaw in the packer? or maybe a unintended side effect of the “os.path.dirname(os.path.abspath(‘file’))” code? anyway I slipped the folder with just those txt files in the targeted location and the game booted up with no sound but it worked okay, does anyone have any clues what is going on?

Edit: I tried to load from it’s package icon and it crashed again, maybe it was grabbing the terminal’s point location?


Edit2:You know what? after getting the sound working, i,m going to settle with this method and explain that is in alpha, with instructions on how to run the game, thank you Yonnji, wezu, Thaumaturge, and Moguri for you guys help.

Before I consider this topic solved, though, I going to borrow a family member’s windows 7 netbook to see if I can get it running on it.

When scripts are frozen (the name for the process that Panda uses to bundle the Python scripts into the binary) they lose their own file path and thus __file__ is empty.

the file path is not empty as it was pointing to the user’s folder, when I placed the txt files in the user folder it worked.

Edit: maybe it is empty, and the user’s folder is the default?