pack3d and python classes in lower directories

I have been attempting to start trying to convert a program I had been previously working on into a web-based app, but I am not getting very far.

My program has a number of classes set in subfolders (libs, modelclasses,etc) of the main.py folder. These folders all contain a blank init.py file and the various classes.

In my code they had been invoked like this:

from libs.User import User

where libs is a subfolder, with a blank init.py and User.py

The program packs into the p3d with no errors, but as soon as the import line is invoked it crashes with the error:

from libs.User import User
ImportError: No module named User

The code is fine running normally. What is the trick? Does ppackage.pyd have to be used? If so is it only available in the CVS?

Hmm, I think that should work. I’ll have to see if I can reproduce this problem.

David

I have recreated the issue with a very simple ‘program’:

main.py:

import direct.directbase.DirectStart
import os,sys

Figure out what directory this program is in.

MYDIR=os.path.abspath(sys.path[0])
sys.path.append(MYDIR)

print ‘SYS PATH’,sys.path

from libs.User import User

me=User()

run()

one folder named ‘libs’ containing a blank init.py
and User.py:

class User():
def init(self):
print “user is initialized”;

Nothing exciting, runs fine in python.
Packed with command:(the main.py in a subfolder ‘test’):

panda3d packp3d.p3d -o local_test.p3d -d test/

The output from running the above:

/$ panda3d local_test.p3d
DirectStart: Starting the game.
:display: loading display module: libpandagl.so
:display: loading display module: libtinydisplay.so
Known pipe types:
glxGraphicsPipe
TinyXGraphicsPipe
TinyOffscreenGraphicsPipe
(all display modules loaded.)
:ShowBase: Default graphics pipe is glxGraphicsPipe (OpenGL).
:display: Unable to set window properties: !undecorated
:ShowBase: Successfully opened window of type glxGraphicsWindow (OpenGL)
:audio: NullAudioManager
:audio: NullAudioManager
:ShowBase: dev == 0
SYS PATH[’/home/nibbol/.panda3d/hosts/runtime.panda3d.org_96a0ec538744def6/panda3d/cmu_1.7’, ‘/home/nibbol/.panda3d/hosts/runtime.panda3d.org_96a0ec538744def6/panda3d/cmu_1.7’, ‘lib/python26.zip’, ‘lib/python2.6/’, ‘lib/python2.6/plat-linux2’, ‘lib/python2.6/lib-tk’, ‘lib/python2.6/lib-old’, ‘lib/python2.6/lib-dynload’, ‘/mf’, ‘/home/nibbol/.panda3d/hosts/runtime.panda3d.org_96a0ec538744def6/panda3d/cmu_1.7’]
Traceback (most recent call last):
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py”, line 352, in __taskChainDispatch
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py”, line 410, in __dispatch
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py”, line 490, in __startIfReady
File “VFSImporter”, line 153, in load_module
File “/media/HP/sites/sigilis/CLIENT/test/main.py”, line 21, in
from libs.User import User
ImportError: No module named User
:task(error): Exception occurred in PythonTask Messenger-default
Traceback (most recent call last):
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py”, line 408, in run
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py”, line 496, in run
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py”, line 454, in step
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py”, line 352, in __taskChainDispatch
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py”, line 410, in __dispatch
File “/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py”, line 490, in __startIfReady
File “VFSImporter”, line 153, in load_module
File “/media/HP/sites/sigilis/CLIENT/test/main.py”, line 21, in
from libs.User import User
ImportError: No module named User
:TaskManager: TaskManager.destroy()
:display: Closing glxGraphicsWindow
Successfully joined thread: 0
Failure on startup.

This is indeed a bug in packp3d, my apologies. I am working on a solution now.

David

I have checked in a fix for the next runtime build.

David