Python 3 Support

Hi!

I tried, unsuccessfully, to get Panda3D to work with Python 3. The issue was trying to get all of the third-party libraries to compile. I am assuming that I did something wrong. I did use the 1.10 version of Panda with Python 3.4.

I just downloaded the older version of Python 2.x and installed Panda3D 1.9. No immediate problems. Asteroids and Fireflies works great.

Any thoughts on Python 3? Or should I just stick to the older Python for now?

Thanks!

Josh

You can find pre-compiled development snapshots of 1.10 for Python 3.6 on this page. Panda 1.9 has preliminary support for Python 3, but 1.10 improves the support, and I would recommend using 1.10 for any Python 3 projects.

The Python 3 support in the master branch is first-class, and many (myself included) use it exclusively, so I can vouch for that.

There are precompiled thirdparty libraries available on this page:

including links to a CMake script to conveniently build (almost) all of them.

Shoot! I forgot to login!

Thanks for the answers! I’m downloading one of the SDKs now. Let’s see if it works.

Thanks again!!

Josh

I must have done something wrong. Didn’t work right out of the box. I’ll have to figure it out. I’m off to do taxes right now, so graphics programming isn’t on the todo list this morning!

Best,

J

I reinstalled Panda from this http://www.panda3d.org/download.php?platform=macosx&version=devel&sdk “Panda3D-SDK-1.10.0-2acde88-MacOSX10.6.dmg” and I got this result:

asteroids $ python3 --version
Python 3.6.0
asteroids $ python3 main.py
Traceback (most recent call last):
  File "main.py", line 16, in <module>
    from direct.showbase.ShowBase import ShowBase
  File "/Developer/Panda3D/direct/showbase/ShowBase.py", line 12, in <module>
    from panda3d.core import *
ImportError: dlopen(/Developer/Panda3D/panda3d/core.so, 2): Symbol not found: __Py_ZeroStruct
  Referenced from: /Developer/Panda3D/panda3d/../lib/libp3interrogatedb.1.10.dylib
  Expected in: flat namespace
 in /Developer/Panda3D/panda3d/../lib/libp3interrogatedb.1.10.dylib
asteroids $

Per [url]Installing on Ubunutu 7.10]:

test1 $ python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', '/Developer/Panda3D', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload']
>>>

I did a vanilla install from the dmg. I only had a couple of minutes this morning so my debug time is limited.

I did notice this other posting: [url]Panda3D OSX issues Python linking]. That there was reference to a bug in GCC:

In [url]Installing on Ubunutu 7.10] there is reference to different version of Python:

Did I grab the wrong version? I can swap out the Python version if need be. When I tried compiling Panda, I got bogged down with the third party apps. Is it worth getting that pipeline working to have the latest Panda? I’m just starting out with the engine, so I don’t need all the bells and whistles. I have a lot to learn as it is! I’m not sure if I mentioned this, but I’m running a Mac with OS 10.12.2.

As a side note, should I code my Python code differently to support Cython? I was planning on using CTypes within Python. Good idea or not worth the effort?

Thanks for the input!

Josh

Yes, you grabbed a build of Panda that was compiled for Python 2.6. It will not work with Python 3.6. You would need to grab a build of Panda that is specifically marked “py3.6” (there are some listed).

It may be easier to install Panda3D with “pip”, using the following command:

python3 -m pip install --extra-index-url https://archive.panda3d.org/ panda3d

This will make sure to grab a build that will work for your version of Python. Although the pip packages are a bit experimental at this point, so let me know if you run into any trouble.

Sweet!

Panda3DExamples $ cd asteroids/
asteroids $ pwd
/Users/jkuhl/Projects/LearnPanda3D/Panda3DExamples/asteroids
asteroids $ python3 ./main.py
Known pipe types:
  CocoaGraphicsPipe
(all display modules loaded.)
asteroids $ python3 --version
Python 3.6.0
asteroids $

I just loaded up a copy of Asteroids and it worked ok. A quick test of some of the other examples also worked. Very happy.

Thank you!