Error Importing Panda3D in OS X

Return to Installation

Error Importing Panda3D in OS X

Postby rp.beltran » Mon Dec 07, 2015 11:01 pm

I'm using OS X El Capitan and have been unable to setup panda3D on my Macbook Pro.

Running this line from the examples, or the hello world tutorial:
Code: Select all
from direct.showbase.ShowBase import ShowBase

Makes python 2.7.10 quit unexpectedly, and crashes.

My Python path contains '/Developer/Panda3D', and I have tried adding '/Developer/Panda3D/bin' to it as well to see if that helps, but it did not.

I started playing around with it to try and trace back the error, and I found that these commands do not cause errors:
Code: Select all
>>> from direct import showbase
>>> import panda3d
>>> from panda3d import *


These commands cause python to crash
Code: Select all
>>> from direct.showbase import ShowBase
>>> from direct.showbase.ShowBase import *
>>> from panda3d import core
>>> from panda3d import physics
>>> from panda3d import direct


Importing something that clearly does not exist however, such as when I tried:
Code: Select all
from panda3d import fnajkpng

Does not make it crash like that, just prints the error, so it appears to be finding the files, but failing to use them.

So it seems to crash whenever it tries to import anything from 'Panda3D/panda3d'. The files in there are all modules with a .so extension that I am unfamiliar with, but after googling it I saw something someone posted about how you need to import a .so and it isn't working you can try including something like from the same directory as the .so:

Code: Select all
def __bootstrap__():
   global __bootstrap__, __loader__, __file__
   import sys, pkg_resources, imp
   __file__ = pkg_resources.resource_filename(__name__,'direct.so') #or whatever the filename
   __loader__ = None; del __bootstrap__, __loader__
   imp.load_dynamic(__name__,__file__)
__bootstrap__()


This also crashes, and when run from terminal gives the error "ImportError: dynamic module does not define init function (init__main__)". Googling that found nothing that I could directly make use of, but appeared to indicate that this error is associated with python modules written in c/c++ that are not implemented correctly to be used as a python module.

If someone could please point me in the right direction as to how to solve this, that would be great. Probably half the things I wrote down in here aren't useful, but I included everything I have found out. I also checked basic stuff like, is my default python the same as that used in IDLE, and I believe it is. Thank you for your help.
rp.beltran
 
Posts: 3
Joined: Mon Dec 07, 2015 10:40 pm

Re: Error Importing Panda3D in OS X

Postby rp.beltran » Tue Dec 08, 2015 1:30 am

My bad, I did not realize I had to use ppython instead of python. Looking back I found this in the tutorials, but I think it could have been emphasized more, because I personally just skimmed over the terminal commands stuff because I usually am not running my programs from terminal, (since IDLE, Sublime, and all of those make it faster to run it without leaving the window). Is there any plans to support the standard python instead of needing to use ppython in the future? It seems like it could add a lot of hassle if you are using other libraries as well for something, and need to set up everything twice.
rp.beltran
 
Posts: 3
Joined: Mon Dec 07, 2015 10:40 pm

Re: Error Importing Panda3D in OS X

Postby rdb » Tue Dec 08, 2015 6:26 am

Panda works out of the box with Apple's standard copy of Python, so there is no need to use ppython. In fact, ppython is just a link to Apple's standard copy of Python.

What I'm guessing you did is install a custom version of Python 2.7 alongside the version of Python 2.7 that is already on your system, one that is incompatible with Panda's build.
rdb
 
Posts: 11223
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Re: Error Importing Panda3D in OS X

Postby rp.beltran » Wed Dec 09, 2015 11:33 am

Hmm, that could be, thanks. I think I setup python with homebrew. I ended up just making a launcher for my application:

Code: Select all
import subprocess
command = "ppython name_of_main_file.py"
output = subprocess.check_output(['bash','-c', command])
print output
rp.beltran
 
Posts: 3
Joined: Mon Dec 07, 2015 10:40 pm

Re: Error Importing Panda3D in OS X

Postby rdb » Wed Dec 21, 2016 8:23 am

There will be a fix for this in the upcoming 1.9.3 release of Panda.
rdb
 
Posts: 11223
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Re: Error Importing Panda3D in OS X

Postby casoteaser » Wed Mar 22, 2017 9:45 pm

thanks for reply . I solved this problem. :)




slotonline
casoteaser
 
Posts: 1
Joined: Wed Mar 22, 2017 9:29 pm


Return to Installation

Who is online

Users browsing this forum: No registered users and 1 guest