import cgi and R6034 Runtime Error

Hi all!

I am using the requests module as part of my game to communicate with a web server, and the line “import cgi” causes an Error when I run the packaged p3d file.

I do not understand why that is, and how I can fix it? Thanks in advance!

Please provide more information. Which version of Panda and Python are you using?

Sorry about that - I’m using Panda 1.9.1 to build the game on Mac 10.11.4/Python2.7. The code runs fine during development. The error message shows up when I run the .p3d file on Windows 7 / Python 2.7, which only have panda runtime installed.

Hmm, one reason I can imagine why this might be happening is that we compile Python and Panda with MSVC 2010 on Windows, whereas many third-party Python modules are compiled with 2008.

Sometimes, this kind of error goes away when installing the Visual C++ 2010/2008 Redistributable or the .NET Framework or something like that. That might be something to try.

Another thing might be to load cgi.pyd into Dependency Walker and see if there are any dependencies that might be the culprit.

Problem is related to this bug with ctypes in python:
bugs.python.org/issue17213

Here is the solution for anyone else with this issue, also applies to importing uuid:

def workaround():
    import platform
    if platform.system() == "Windows":
        import ctypes
        CDLL = ctypes.CDLL
        ctypes.CDLL = None

        from uuid import uuid4
        import cgi

        ctypes.CDLL = CDLL
    else:
        from uuid import uuid4
        import cgi

workaround()