Error when running p3d

I’m running Mac OS X (Leopard), Python 2.5, and Panda3D SDK 1.7. I’ve packed my application (called Shelves) up using:

packp3d -d ./Shelves -o Shelves.p3d -m Shelves.py -r morepy -r pycurl -D

I’ve included two python modules (tornado (web server) and OSC (a udp messaging service) in my application directory. My other dependencies (multiprocessing, urllib, and others) are in morepy and pycurl, as seen in the command above. The application runs fine when I run it like:

ppython Shelves.py

But when I run the p3d like this:

panda3d -i Shelves.p3d

I get these errors:

Attempt to register type HTTPChannel more than once!
Attempt to register type VirtualFile more than once!
Attempt to register type VirtualFileHTTP more than once!
Attempt to register type VirtualFileMount more than once!
Attempt to register type VirtualFileMountHTTP more than once!
Attempt to register type Datagram more than once!
Attempt to register type NodeReferenceCount more than once!
Attempt to register type VirtualFileComposite more than once!
Attempt to register type VirtualFileMountMultifile more than once!
Attempt to register type VirtualFileMountSystem more than once!
Attempt to register type VirtualFileSimple more than once!
Attempt to register type long more than once!
Attempt to register type int more than once!
Attempt to register type uint more than once!
Attempt to register type short more than once!
Attempt to register type ushort more than once!
Attempt to register type char more than once!
Attempt to register type uchar more than once!
Attempt to register type bool more than once!
Attempt to register type double more than once!
Attempt to register type float more than once!
Attempt to register type string more than once!
Attempt to register type int* more than once!
Attempt to register type short* more than once!
Attempt to register type char* more than once!
Attempt to register type bool* more than once!
Attempt to register type double* more than once!
Attempt to register type float* more than once!
Attempt to register type void* more than once!
Attempt to register type pvector more than once!
Attempt to register type ov_set more than once!
Attempt to register type pdeque more than once!
Attempt to register type plist more than once!
Attempt to register type pmap more than once!
Attempt to register type pset more than once!
Invalid TypeHandle index 37!  Is memory corrupt?
Assertion failed: (rnode != (TypeRegistryNode *)NULL), function dec_memory_usage, file dtool/src/dtoolbase/typeHandle.cxx, line 96.

Which seems like some C++ types are getting loaded twice. I’m not sure what’s going on here. Any help is appreciated. Thanks.

Hmm, it does appear that you’re getting two different copies of the Panda3D runtime loaded into memory at once. I don’t know how that could happen, to be honest.

Does the same thing happen when you try to package up a trivially simple application (e.g. one that just imports DirectStart and does nothing else)?

If it’s particular to this application, is it something that you could put online so I could try the same thing?

Thanks!
David

I built a basic p3d package with only directstart and that worked fine. Now I’m pretty sure that this is a python import problem. I rebuilt the p3d of my app with:

packp3d -d ./Shelves -o Shelves.p3d -m Shelves.py -r morepy

(minus the pycurl, which I’ve got in the app directory now and without the -D flag)

and now panda3d Shelves.p3d is giving:

Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/Shelves/Shelves.py", line 1, in <module>
    from Application import BOTApplication
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/Shelves/Application.py", line 6, in <module>
    import Connection, Scene, Server
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/Shelves/Server.py", line 1, in <module>
    from tornado import httpserver, httpclient, ioloop, web, escape
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/Shelves/tornado/web.py", line 52, in <module>
    import escape
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/Shelves/tornado/escape.py", line 21, in <module>
    import xml.sax.saxutils
  File "VFSImporter", line 446, in load_module
ImportError

tornado is trying to load the xml.sax.saxutils modules, which is in the morepy package, so I’m not sure why it can’t find it.

My current p3d is here:

minneapolisartonwheels.org/bot/p … helves.p3d

Hmm, sax has always been a troublesome module. It’s not an ordinary module, but it instead plays games with the importer at runtime. I wonder if that’s what’s causing problems?

I can’t do anything with the p3d file, I’d need to see your source code as well. But maybe I can just try to replicate this with my own code that tries to import sax.

For the record, it’s generally preferable to use the prepared version of a particular package (e.g. pycurl) than to copy it into your application directory, when there is an option. Using the prepared version means that (a) your p3d file will be smaller, (b) your p3d file will be more likely to be cross-platform, and © hopefully, issues like this will be less likely to develop.

Of course, that’s just pycurl. This sax problem is something different. :frowning:

David

I think I’ve almost got it working. I’ve rebuilt it using twisted (since there is a package for that), and now I get:

Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/Shelves/Shelves.py", line 6, in <module>
    shelves.createWebServer(port = 8080)
  File "/Users/aaron/Desktop/BOTApps/Shelves/Application.py", line 134, in createWebServer
    self.webServer = Server.WebServer(port = port, appFolder = self.applicationFolder, dataFolder = self.dataFolder)
  File "/Users/aaron/Desktop/BOTApps/Shelves/Server.py", line 41, in __init__
    TWReactor.listenTCP(self.port, self.site)
AttributeError: 'module' object has no attribute 'listenTCP'

I’m importing twisted.internet.reactor as TWReator here, but the results are the same without the rename. Is this a version issue? Maybe the version of twisted on the panda server doesn’t support twisted.internet.reactor.listenTCP()?

Hmm, possibly. I know little about twisted. Maybe it does some funny dynamic tricks at importing too?

rdb, do you know which version of twisted is packaged?

David

Sorry, I don’t know off the top of my head, and it’s a bit tricky for me to find out at this point, as I don’t have access to my Windows VM from FreeBSD.

I did a simple test like this:

from direct.showbase.ShowBase import ShowBase
import os
from twisted.web import server, client, static
from twisted.web.resource import Resource
from twisted.internet.task import LoopingCall
from twisted.internet import reactor
 
class MyApp(ShowBase):
  def __init__(self):
    ShowBase.__init__(self)
    myTeapot = loader.loadModel('teapot')
    myTeapot.setScale(0.2)
    myTeapot.reparentTo(render)

app = MyApp()
webFolder = os.path.join(os.getcwd(), 'web')
webRoot = static.File(webFolder)
webRoot.putChild('css', static.File(os.path.join(webFolder, 'css'), defaultType = 'text/css'))
webRoot.putChild('js', static.File(os.path.join(webFolder, 'js'), defaultType = 'text/javascript'))
webRoot.putChild('png', static.File(os.path.join(webFolder, 'png'), defaultType = 'image/png'))
site = server.Site(webRoot)
LoopingCall(taskMgr.step).start(1 / 30)
reactor.listenTCP(8080, site)
reactor.run()

When I run it with python it works great, I see the teapot and can get to the website, but when I package it with:

packp3d -d ./test -o test.p3d -m twistedtest.py -r morepy -r twisted

and then run panda3d test.p3d, I get this error:

Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/test/twistedtest.py", line 22, in <module>
    LoopingCall(taskMgr.step).start(1 / 30)
  File "/Users/rdb/Library/Python/2.6/site-packages/Twisted-9.0.0-py2.6-macosx-10.3-fat.egg/twisted/internet/task.py", line 158, in start
AttributeError: 'module' object has no attribute 'seconds'
:task(error): Exception occurred in PythonTask Messenger-default
Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Desktop/BOTApps/test/twistedtest.py", line 22, in <module>
    LoopingCall(taskMgr.step).start(1 / 30)
  File "/Users/rdb/Library/Python/2.6/site-packages/Twisted-9.0.0-py2.6-macosx-10.3-fat.egg/twisted/internet/task.py", line 158, in start
AttributeError: 'module' object has no attribute 'seconds'
:TaskManager: TaskManager.destroy()

Is there a name conflict with ‘task’?

Still getting this same error. Has anyone had success in using the twisted module when building a .p3d?

I think the problem above is that the Panda package for twisted is version 9, whereas I’m using version 10. I made my own package with version 10, which downloads correctly when I run the .p3d, but gives this error:

Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Projects/MAW/BOT/BOTApps/Shelves/Shelves.py", line 1, in <module>
    from Application import BOTApplication
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Projects/MAW/BOT/BOTApps/Shelves/Application.py", line 7, in <module>
    import Connection, Scene, Server
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Projects/MAW/BOT/BOTApps/Shelves/Server.py", line 2, in <module>
    from twisted.web import server, client, static
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/__init__.py", line 19, in <module>
    from zope.interface import Interface
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/zope/__init__.py", line 3, in <module>
    import pkg_resources
  File "VFSImporter", line 153, in load_module
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 651, in <module>
    class Environment(object):
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 654, in Environment
    def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR):
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 55, in get_supported_platform
    plat = get_build_platform(); m = macosVersionString.match(plat)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 181, in get_build_platform
    plat = get_platform()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/util.py", line 78, in get_platform
    cfgvars = get_config_vars()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/sysconfig.py", line 504, in get_config_vars
    func()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/sysconfig.py", line 363, in _init_posix
    raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /lib/python2.6/config/Makefile (None)
Successfully joined thread: 0
Failure on startup.

Is this an issue with how I’m building the package? My pdef looks like this:

import sys
sys.path.append('/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python')
sys.path.append('/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5')

import twisted

packager.setHost('http://minneapolisartonwheels.org/bot/packages/')

class twisted10(package):
  config(display_name = "Twisted 10.0.0 for Panda3D")
  module('twisted')

I’m pretty sure we build with Python 2.6 for the rtdist build, so you will need to point your pdef file to a version of Twisted built for Python 2.6.

David

Thanks David, that worked. However, I’ve got the same issue whether I use my version 10 twisted package, or the Panda3d one.

Traceback (most recent call last):
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/Users/rdb/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/Users/aaron/Projects/MAW/BOT/BOTApps/test/twistedtest.py", line 36, in <module>
    LoopingCall(taskMgr.step).start(fps)
  File "/Users/rdb/Library/Python/2.6/site-packages/Twisted-9.0.0-py2.6-macosx-10.3-fat.egg/twisted/internet/task.py", line 158, in start
AttributeError: 'module' object has no attribute 'seconds'
:TaskManager: TaskManager.destroy()
:display: Closing osxGraphicsWindow
Successfully joined thread: 0
Failure on startup.

This is the same issue as before. If I run it with “python twistedtest.py” it works fine (i see the teapot spinning and the web server works), but as a .p3d it gives this error. Here’s the test script I’ve been working with, for reference:

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
import os
from twisted.web import server, client, static
from twisted.internet.task import LoopingCall
from twisted.internet import reactor
import math

class MyApp(ShowBase):
  def __init__(self):
    ShowBase.__init__(self)
    self.teapot = loader.loadModel('teapot.bam')
    self.teapot.setScale(0.2)
    self.teapot.setPos(0, 3, -0.2)
    self.teapot.reparentTo(render)
    self.directionalLight = DirectionalLight('directionalLight')
    self.directionalLightNP = render.attachNewNode(self.directionalLight)
    self.directionalLightNP.setPos(-3, -3, 3)
    self.directionalLightNP.lookAt(0, 0, 0)
    render.setLight(self.directionalLightNP)
    
  def rotateTeapot(self, task):
    self.teapot.setHpr(self.teapot.getH() + ((math.pi / 192) * 180), self.teapot.getP(), self.teapot.getR())
    return task.again

app = MyApp()
taskMgr.add(app.rotateTeapot, "Rotate Teapot")
webFolder = os.path.join(os.getcwd(), 'web')
print(str(webFolder))
webRoot = static.File(webFolder)
webRoot.putChild('css', static.File(os.path.join(webFolder, 'css'), defaultType = 'text/css'))
webRoot.putChild('js', static.File(os.path.join(webFolder, 'js'), defaultType = 'text/javascript'))
webRoot.putChild('png', static.File(os.path.join(webFolder, 'png'), defaultType = 'image/png'))
site = server.Site(webRoot)
fps = 1 / 30
LoopingCall(taskMgr.step).start(fps)
reactor.listenTCP(8080, site)
reactor.run()

My guess is that twisted is playing some games with sys.modules, or doing other non-standard tricks, in order to construct its namespace at runtime. If that is indeed the case, we’ll have to investigate this specifically and figure out how to deal with whatever special-case stuff twisted is doing.

David

Just an update:

I’m now using Bottle as a web server, with which I can package my .p3d successfully. This may be a good option for others looking for a lightweight web server to use with Panda3D.