Adding Panda to Pythons PATH

Hi

I’m new here, as well being new to Panda and Python really. Looking forward to contributing to the success of such a cool project.

I am trying to test my Panda Installation. Just using the Hello World program from the manual but I running in to a few problems finding Panda modules.

I did wight a little script to add panda to pythons PATH but as far as I can tell in did not work.

import sys

sys.path.append("/Developer/Panda3D/")

HelloPanda.py

from direct.showbase.ShowBase import ShowBase
 
class MyApp(ShowBase):
 
    def __init__(self):
        ShowBase.__init__(self)
 
app = MyApp()
app.run()

import direct.directbase.DirectStart
 
run()

Traceback (most recent call last):
File “HelloPanda.py”, line 1, in
from direct.showbase.ShowBase import ShowBase
ImportError: No module named direct.showbase.ShowBase

Any assistance would be most welcome.

Hey, welcome to the forums! =)

The correct modules are automatically added to the PYTHONPATH by the installer. The problem is probably that you’re not running it with the version of Python that Panda3D was compiled with. The Mac OSX SDK is built against Python 2.5, so you’ll need to run it with that version (it should already be installed with OSX). To be sure, you can always run “ppython” instead of “python”, which is a handy symlink that always points to the version of Python that that Panda3D build is compiled for.

Amazing! Thanks so much rdb!

It sounds like your original problem was solved, but since you are new to Python I should point out a possible misunderstanding implied by the python code you originally tried.

That is: sys.path.append will only modify the Python path within one running process; it will affect imports that occur later in that process.

If you run the script quoted above, then run another Python script (like your HelloPanda.py) separately, the first script will have no effect on the second one.