Python 3 Support

Return to Installation

Python 3 Support

Postby JK61 » Mon Jan 30, 2017 3:46 am

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
JK61
 
Posts: 11
Joined: Mon Jan 30, 2017 3:41 am
Location: Pennsylvania, USA

Re: Python 3 Support

Postby Moguri » Mon Jan 30, 2017 11:17 am

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.
Moguri
 
Posts: 57
Joined: Fri May 15, 2015 1:35 pm

Re: Python 3 Support

Postby rdb » Thu Feb 02, 2017 8:54 am

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:
viewtopic.php?f=9&t=18775
including links to a CMake script to conveniently build (almost) all of them.
rdb
 
Posts: 11223
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Re: Python 3 Support

Postby JK61 » Sun Feb 05, 2017 7:59 am

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
JK61
 
Posts: 11
Joined: Mon Jan 30, 2017 3:41 am
Location: Pennsylvania, USA

Re: Python 3 Support

Postby JK61 » Sun Feb 05, 2017 8:11 am

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
JK61
 
Posts: 11
Joined: Mon Jan 30, 2017 3:41 am
Location: Pennsylvania, USA

Re: Python 3 Support

Postby JK61 » Sun Feb 12, 2017 8:54 am

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:

Code: Select all
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 https://www.panda3d.org/forums/viewtopic.php?t=3904#20510:

Code: Select all
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: https://www.panda3d.org/forums/viewtopic.php?f=5&t=19223. That there was reference to a bug in GCC:

Apparently this is caused by a bug in GCC. I'm still looking into a workaround, but if you compile with clang instead, you shouldn't have trouble. You can do this by setting the CC and CXX env variables to clang and clang++ respectively before invoking makepanda. You may have to make a clean build by deleting your "built" directory first.


In https://www.panda3d.org/forums/viewtopic.php?t=3904#20510 there is reference to different version of Python:

Python packages need to be compiled for a particular variant of python. For example, a package that works with python 2.4 will not work with python 2.5.


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
JK61
 
Posts: 11
Joined: Mon Jan 30, 2017 3:41 am
Location: Pennsylvania, USA

Re: Python 3 Support

Postby rdb » Sun Feb 12, 2017 8:21 pm

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:
Code: Select all
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.
rdb
 
Posts: 11223
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Re: Python 3 Support

Postby JK61 » Mon Feb 13, 2017 3:01 pm

Sweet!

Code: Select all
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!
JK61
 
Posts: 11
Joined: Mon Jan 30, 2017 3:41 am
Location: Pennsylvania, USA


Return to Installation

Who is online

Users browsing this forum: No registered users and 1 guest