Tip - how to configure installed Python to import Panda3D

I just thought of doing this, but I can’t try it until I get home.

  • If you already have Python installed, say in c:\Python23 under Windows.
  • If you have Panda3D installed and it was compiled for Python 2.3 and is installed in c:\Panda-1.0.2

Then create a new panda.pth file in c:\Python23\site-packages that contains the following


In theory you should be able to then double click on a sample’s python file (not the command file that runs it). Or alternatively you should be able to develop and run a Panda3D application outside of the Panda3D directory. Python should be able to import the Panda3D libraries.

I don’t know if this works yet, so give it a try! :slight_smile:

Ok so the theory works but Panda3D is built for Python 2.2 but I have Python 2.4 installed. So unless someone has a build for 2.4 they could host… :slight_smile:

Ok I tried this under Fedora Core4. I built Panda3d from CVS and moved it to /opt/panda3d. I added /opt/panda3d/built/lib to /etc/ld.so.conf.

I created a file in/usr/lib/python2.4/site-packages/panda3d.pth, which contains a single line:


I also created an init.py file in /opt/panda3d/built.

When I run a sample I get:

[mike@localhost Feature-Tutorials--Fog]$ python Tut-Infinite-Tunnel.py DirectStart: Starting the game.
Traceback (most recent call last):
  File "Tut-Infinite-Tunnel.py", line 13, in ?
    import direct.directbase.DirectStart
  File "/opt/panda3d/built/direct/../../direct/src/directbase/DirectStart.py", line 3, in ?
    from direct.showbase import ShowBase
  File "/opt/panda3d/built/direct/../../direct/src/showbase/ShowBase.py", line 6, in ?
    from pandac.PandaModules import *
  File "/opt/panda3d/built/pandac/PandaModules.py", line 1, in ?
    from libpandaexpressModules import *
  File "/opt/panda3d/built/pandac/libpandaexpressModules.py", line 1, in ?
    from libpandaexpress import *
ImportError: No module named libpandaexpress

Any ideas?

Yes, I know what’s going on. When python searches for a shared library, it searches the PYTHONPATH, not the LD_LIBRARY_PATH. So that means that the panda shared objects need to be in both paths. In my RPM distributions, I achieve this by symbolically linking the libraries into the python directory. I suppose you could also add another PTH file.

  • Josh

Let me interject, for the record, that there appears to be a critical bug with the gcc-4.0.0 compiler that is distributed with FC4. It does successfully compile Panda, and that compiled Panda will run successfully as a standalone executable, without Python (e.g. if you use only pview or any of the command-line tools), but when you try to import it into Python you are likely to get a segment fault error, due to some incorrect code generated by the compiler.

The solution is to install a different compiler, e.g. gcc-4.0.1, or gcc-3.4.4; any version other than 4.0.0 will work fine. This is a fairly involved process, but it’s not too difficult–I’ve already done it successfully on my two different FC4 machines. Or, a user of FC4 will need to wait for Josh to provide a prebuilt rpm package (sorry, Josh, you’ll have to install gcc-4.0.1 for yourself).


Well that worked - thanks! And the tutorials ran (at least the fog and lighting ones) with no segmentation faults.

g++ (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)


Alternatively change the panda3d.pth file in site-packages to be:


That seems to work as well.

Great! Maybe it was just me somehow?


Check your build number - maybe I upgraded mine using yum and you didn’t?

That does appear to be the difference. I had trouble getting yum to work inside the corporate firewall, but I finally got it working, and am currently download a whole slew of stuff–including changes to libgcc and libstdc++. We’ll see if this solves the compiler issue, but I think it’s very likely that it will.

That’s good news; it means people with FC4 will be able to easily compile Panda after all.


Yeah - the best part is being able to use Boa Constructor or Spe to develop Panda3D apps, including the debugger and also any GUI designer tools for creating tools! 8)