Issue with panda setup

Well, I get the impression that the fault must be in part my own because no one else seems to be asking about this, but I haven’t been able to get Panda to work. From the doc files I’ve been able to find so far it seems like I should be able to simply install the latest python binary and then the panda binary, and it should magically setup correctly, and I should be able to run the sample python files with no problem.
Unfortunately this is of course not the case; running the tutorial.py in the samples directory gives me the error:
Traceback (most recent call last):
File “PandaDemo.py”, line 1, in ?
from ShowBaseGlobal import *
ImportError: No module named ShowBaseGlobal

What do I have to do to make it find the module?

By accident I noticed that the binary distribution includes its own copy of python and, though it doesn’t seem to associate files with it or put the python.exe file in the cmd path (at least on XP), that copy of python is configured to work with panda. So, sweet, it works.

As an aside, the tutorial program seems to be missing some audio files (it says it fails to load a few; glancing at the installed files I fail to find them as well, so either they’re not there or they’re just misplaced.

Also, I know for a fact that a few other people had had trouble with this as well (to the point that they gave up on panda) so I think it might be worth the time to (a) mention in an obvious location, eg, on the download page write “This installer installs its own, pre-set-up version of Python that you must use; do not expect to use an already installed version.” and (b) make the installer at least add python to the path; it already adds a bunch of stuff there, so it doesn’t seem like it would be a problem. If it is a problem, you could at least give the option.

Anyway, aside from that it looks great.
Thanks!

you may want to modify the Building Virtual Worlds tutorial .doc file so it doesn’t say this:

That implied to me that I did need to install python seperately, as it does seem that doc expects on to use the panda windows installer.

These things are on the todo list. To keep us honest, you might want to post a bug:
sourceforge.net/tracker/?func=ad … tid=427161

The easiest thing to do is to explicitly set the PYTHONPATH environmental variable:


set PYTHONPATH=C:\Panda\lib;C:\Panda\lib\Py;C:\Panda\direct\src\showbase

Incidentally, why on earth does Panda use its own separate Python installation? I realize that it can be a considerable amount of work maintaining a Python module and keeping it up to date with the latest versions, but it’s the only way to take advantage of the full power of Python and all the other modules available for it. Shouldn’t this be #1 on the list of things to remedy?

It’s very important, as we can see from this thread, that people are able to get Panda up and running as quickly as possible, without encountering errors.

So it’s not just a matter of making Panda work with the latest version of Python, but making it work with whatever version of Python is on the user’s machine, or even with no version of Python at all on the user’s machine. There’s no requirement that you use the version we ship. We just want to be sure it will work as shipped.

Incidentally, at PyCON last week, Guido van Rossum actually said that this is the way he would approach the distribution problem himself if he were distributing a Python based application.

I finally managed to get Panda to build on Linux, after all sorts of crazy problems, but now I’m finding it impossible to get any Python code to work with it.

I’m using the default installation location of /usr/local/panda/.

I figured out that Panda’s version of python is named “ppython” and it gets installed in /usr/local/panda/bin. However, none of the python modules (which reside in direct/src//.py in the source code) get installed in /u/l/panda.

I noticed there is a direct.pth in direct/src/configfiles, but its contents don’t seem to make any sense. I decided to just make all the .py files that are spread throughout direct/src/*/ reside in a directory in my PYTHONPATH (using a symlink hack). This got me closer, but I don’t have the motivation to dive deeper to solve my current problem::

File “/home/chris/Projects/PANDA_SUCKS/ShowBase.py”, line 7, in ?
from PandaModules import *
ImportError: No module named PandaModules

There is no PandaModules.py anywhere in the source of panda3d. Upon investigation, I notice that it seems to be created dynamically by some “squeeze” technique.

Search search search. What’s this? genPyCode and generatePythonCode. Hrm, that might be useful. I tried running “genPyCode linux” after reading the first few lines of the file, but it gives me errors about not being able to open generatePythonCode; I don’t know why it can’t.

This is where I get too annoyed to continue investigation; shouldn’t this stuff be done automatically during the build or install process?

Rant ahead:

I also strongly recommend that the Panda people doing Python interfaces clean up the mess. All of these modules ought to be put into a “panda” package, instead of having dozens and dozens of top-level modules (all spread throughout several directories in the source!). And this squeeze tool looks like absolute madness. I work on several large (by Python standards) projects; the state of the Python code in the Panda source is a nightmare.

– Christopher Armstrong

Some of the problems you are encountering is a difference in philosophy between a live source tree that we are actively developing, and a static tree produced for someone else’s use. We have our Python source files distributed among several directories in direct/src/*, because that keeps the code organized and easier to maintain. Arguably, you don’t care about that, and would rather see them all in one directory. Fair enough; perhaps part of the packaging of a distribution should involve copying these out.

In the meantime, you will need to understand a little about how it is supposed to work. ppython is actually a script that, on Linux, doesn’t do very much. It’s mainly useful in the Windows/Cygwin environment, to de-cygwinify the path names.

The big piece that you are missing is that you need to have direct/src/showbase on your PYTHONPATH. (You will probably want to put /usr/local/panda/lib/py on there too, for the output of genPyCode; see below.)

This puts sitecustomize.py where Python can find it and load it at startup time. You will also need to set the environment variable PLAYER to the directory above direct. Then sitecustomize.py is supposed to scan for the *.pth files and add the named directories onto your PYTHONPATH at load time, so that the dozens of separate directories can be loaded as if they were all in the same place.

This is a great system for doing live development in the tree, because it allows us to keep our code organized, creating or removing directories as we need, without having to worry about a separate install step.

Now, once you have that going, you can address genPyCode. This is the script that runs the Python part of interrogate. It is unfortunate that it is a necessary step and it kind of has to be done by hand, after the build process is otherwise finished, because there’s not one ‘make install’ rule for the entire dtool/panda/direct tree. One day we hope to eliminate the need for this step, but it remains necessary for now.

Try setting the environment variable PANDA_INSTALL to /usr/local/panda, and running “genPyCode install”. If it works, you’ll see it generate some output, and end with a comment about squeezing PandaModules. The generated output files will be dumped into /usr/local/panda/lib/py. (You can try including the parameter -n if something goes wrong with the squeeze step.)

Looks like we have a major documentation bug in the INSTALL file. I can’t believe all of this stuff was left out!

David

Actually, no! I like nested structures, but ones that are actually Python packages (init.py and so forth), not just a bunch of directories with files that actually show up in a flat namespace (the toplevel one) in Python. i.e., like how every other python package is laid out in their source trees :slight_smile: Then I can just add the root directory of the python package to my PYTHONPATH and be done with it.

I’ll try the following stuff after I get some sleep. Thanks a lot for the great reply! I’ll see if I can manage to integrate my new-found knowledge into the INSTALL file once I get it working.

Ok… I had some problems with this, but I got a lot closer now.

I also had to add /usr/local/panda/lib to my PYTHONPATH, because python code tried to import extension modules that existed there. I also had to make sure I was in my root panda directory (genPyCode tries to access paths relative to it).

The first time I ran “genPyCode install”, I got this error at the end:

SQUEEZING PandaModules
python: can’t open file ‘/src/showbase/pandaSqueezer.py’

Then I did as you said and ran “genPyCode -n install”. This seemed to resolve the problem, ending with:

RENAMING PandaModulesUnsqueezed.py to PandaModules.py
DONE

I have no idea why, though.

Also, I got a bunch of non-fatal errors in the genPyCode output like this:

:interrogatedb(error): Unable to find libinterval.in on .:.
:interrogatedb(error): Unable to find libdeadrec.in on .:.
:interrogatedb(error): Unable to find libshowbase.in on .:.
:interrogatedb(error): Unable to find libdcparser.in on .:.

So, let’s try to run some python programs.

chris@radii ~/RubiksCube% python rubiksCube.py 
Site customize for Panda:
  Appending paths based on $PLAYER
  Appending paths in /home/chris/Projects/panda/panda/src/configfiles/panda.pth
  Appending paths in /home/chris/Projects/panda/direct/src/configfiles/direct.pth
Traceback (most recent call last):
  File "rubiksCube.py", line 4, in ?
    from ShowBaseGlobal import *
  File "/home/chris/Projects/panda/direct/src/showbase/ShowBaseGlobal.py", line 3, in ?
    from ShowBase import *
  File "/home/chris/Projects/panda/direct/src/showbase/ShowBase.py", line 10, in ?
    from TaskManagerGlobal import *
  File "/home/chris/Projects/panda/direct/src/task/TaskManagerGlobal.py", line 2, in ?
    import Task
  File "/home/chris/Projects/panda/direct/src/task/Task.py", line 21, in ?
    globalClock = ClockObject.getGlobalClock()
NameError: name 'ClockObject' is not defined

chris@radii ~/DemoProject% python PandaDemo.py 
Site customize for Panda:
  Appending paths based on $PLAYER
  Appending paths in /home/chris/Projects/panda/panda/src/configfiles/panda.pth
  Appending paths in /home/chris/Projects/panda/direct/src/configfiles/direct.pth
Traceback (most recent call last):
  File "PandaDemo.py", line 1, in ?
    from ShowBaseGlobal import *
  File "/home/chris/Projects/panda/direct/src/showbase/ShowBaseGlobal.py", line 3, in ?
    from ShowBase import *
  File "/home/chris/Projects/panda/direct/src/showbase/ShowBase.py", line 10, in ?
    from TaskManagerGlobal import *
  File "/home/chris/Projects/panda/direct/src/task/TaskManagerGlobal.py", line 2, in ?
    import Task
  File "/home/chris/Projects/panda/direct/src/task/Task.py", line 21, in ?
    globalClock = ClockObject.getGlobalClock()
NameError: name 'ClockObject' is not defined

Hmm, same error in both. Looks like the code is relying on something popping up from an ‘import *’ which isn’t. (import * is bad! bad!)

Any hints?

Ok, you are indeed very close.

First, there are a couple of problems in the genPyCode script, which I have just fixed. (We occasionally accidentally introduce problems in the lesser-used codepaths, since our build scripts are a little different in the VR Studio. Sorry about that.)

You can either check out the latest genPyCode from SourceForge CVS (version 1.36, if it’s available on anonymous checkout yet), or you can download the version I’ve just put on ddrose.com/genPyCode .

Second, there are two more environment variables you will need to define. Set PLAYER to the root of the source tree (the directory above panda, direct, and dtool), and set ETC_PATH to /usr/local/panda/etc. (The need for ETC_PATH is unintended; it’s an oversight which I will fix shortly.)

The non-fatal error messages about being unable to load the *.in files are actually what’s causing your problems with Python code. Without the *.in files it wasn’t able to instrument the code properly.

With the latest genPyCode and these two environment variables, you should be able to run genPyCode successfully with or without the -n parameter.

David

Closer still!

I did what you told me and it seemed to go smoothly, with no apparent warnings or errors in the output.

However, PandaDemo and RubiksCube still aren’t working. PandaDemo gets quite far. When I run it, I get the splash screen with the “Click to start” button. When this happens, though, I get a bunch of output followed by a traceback:


chris@radii ~/DemoProject% python PandaDemo.py
Site customize for Panda:  
  Appending paths based on $PLAYER
  Appending paths in /home/chris/Projects/panda/panda/src/configfiles/panda.pth
  Appending paths in /home/chris/Projects/panda/direct/src/configfiles/direct.pth
Warning: DirectNotify: category 'Interval' already exists
:display: loading display module: libpandagl.so
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:04-03-2004 00:58:01 ShowBase(info): Default graphics pipe is OpenGL (glxGraphicsPipe).
:display:glxdisplay: Selected suitable GLX fbconfig.
:display: Created glxGraphicsWindow
:audio(error):   LoadLibrary() failed, will use NullAudioManager
:audio(error):     libmiles_audio.so: cannot open shared object file: No such file or directory
:audio: NullAudioManager
:audio: NullAudioManager
:audio: NullAudioManager
:audio: NullAudioManager
:pnmtext: Loaded font Nimbus Sans L Regular Condensed
:gobj: Loading texture /home/chris/DemoProject/models/SplashScreen.tif
:pnmimage:tiff(warning): TIFF file: wrong data type 1 for "XMLPacket"; tag ignored
:pnmimage:tiff(warning): TIFF file: unknown field with tag 34665 (0x8769) encountered
:express(warning): Adjusting global clock's real time by -0.458619 seconds.
:04-03-2004 00:58:02 ShowBase(info): Got window event: origin=(0, 0) size=(640, 480) title="Panda" !undecorated !fullscreen foreground !minimized open !cursor_hidden 
:loader(error): Couldn't load file models/Environment: not found on model path.
Traceback (most recent call last):
  File "PandaDemo.py", line 417, in ?
    run()
  File "/home/chris/Projects/panda/direct/src/showbase/ShowBase.py", line 1503, in run
    self.taskMgr.run()
  File "/home/chris/Projects/panda/direct/src/task/Task.py", line 769, in run
    self.step()
  File "/home/chris/Projects/panda/direct/src/task/Task.py", line 714, in step
    self.__stepThroughList(taskPriList)
  File "/home/chris/Projects/panda/direct/src/task/Task.py", line 654, in __stepThroughList
    ret = self.__executeTask(task)
  File "/home/chris/Projects/panda/direct/src/task/Task.py", line 604, in __executeTask
    ret = task(task)
  File "/home/chris/Projects/panda/direct/src/showbase/EventManager.py", line 32, in eventLoopTask
    self.doEvents()
  File "/home/chris/Projects/panda/direct/src/showbase/EventManager.py", line 26, in doEvents
    self.processEvent(self.eventQueue.dequeueEvent())
  File "/home/chris/Projects/panda/direct/src/showbase/EventManager.py", line 69, in processEvent
    messenger.send(eventName, paramList)
  File "/home/chris/Projects/panda/direct/src/showbase/Messenger.py", line 175, in send
    apply(method, (extraArgs + sentArgs))
  File "/home/chris/Projects/panda/direct/src/gui/DirectButton.py", line 87, in commandFunc
    apply(self['command'], self['extraArgs'])
  File "PandaDemo.py", line 405, in runWorld
    myWorld = World()
  File "PandaDemo.py", line 39, in __init__
    self.environ.setScale(0.5, 0.5, 0.5)
AttributeError: 'NoneType' object has no attribute 'setScale'
:display: Closing glxGraphicsWindow

Running RubiksCube pops up a window for a split-second and then crashes:


chris@radii ~/RubiksCube% python rubiksCube.py 
Site customize for Panda:
  Appending paths based on $PLAYER
  Appending paths in /home/chris/Projects/panda/panda/src/configfiles/panda.pth
  Appending paths in /home/chris/Projects/panda/direct/src/configfiles/direct.pth
Warning: DirectNotify: category 'Interval' already exists
:display: loading display module: libpandagl.so
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:04-03-2004 00:59:11 ShowBase(info): Default graphics pipe is OpenGL (glxGraphicsPipe).
:display:glxdisplay: Selected suitable GLX fbconfig.
:display: Created glxGraphicsWindow
:audio(error):   LoadLibrary() failed, will use NullAudioManager
:audio(error):     libmiles_audio.so: cannot open shared object file: No such file or directory
:audio: NullAudioManager
:audio: NullAudioManager
:audio: NullAudioManager
:audio: NullAudioManager
:pnmtext: Loaded font Nimbus Sans L Regular Condensed
:loader: Loading model gridback
:loader(error): Couldn't load file gridback: not found on model path.
Traceback (most recent call last):
  File "rubiksCube.py", line 374, in ?
    rubik = RubiksCube()
  File "rubiksCube.py", line 78, in __init__
    apply( facelet.setColor, self.colors[face] )
AttributeError: 'NoneType' object has no attribute 'setColor'
:display: Closing glxGraphicsWindow

Congratulations! Your installation of Panda is now properly built.

These stack traces are due to models not being loaded properly. You will need to put at least the following in your Configrc file:

model-path .

Assuming that you are running out of the directory from which the models are to be loaded. Alternatively, you can specify the full path to that directory. (If you want to put multiple directories on the model-path, use a separate line for each one.)

Note that many of the Panda demos on the ETC website, which were developed against the slightly older version of Panda that is available for download there, may have small problems running against the current version of Panda that you have downloaded from SourceForge. If you run into a problem because of a change in the interface, however, it should be a trivial change to fix it, and it may even be an interesting exercise to help you learn about the Panda interface. :slight_smile:

David

Woot :slight_smile:

Ok, this got rubikscube working (after I fixed a bug in rubikscube that was assuming a case-insensitive filesystem :stuck_out_tongue: :stuck_out_tongue: :P). DemoProject is still bailing out with the same error, and I can’t figure out why. I’ll continue investigation.

Thanks, I’ll do that.

Thanks for all of your help, David, it’s greatly appreciated.