Search code examples
pythonpygletcocos2d-python

Cocos2d and Pyglet installation non-functional


After installing both by moving them into the Lib folder of my python installation, I get this error when trying to import cocos.

Traceback (most recent call last):
  File "C:/Users/test/PycharmProjects/Testing/main.py", line 1, in <module>
    import cocos
  File "C:\Python34\lib\cocos\__init__.py", line 69, in <module>
    import os, pyglet
  File "C:\Python34\lib\pyglet\__init__.py", line 276
    print '[%d] %s%s %s' % (thread, indent, name, location)
                   ^
SyntaxError: invalid syntax

Solution

  • You are using Python 3, but attempting to use Python 2's print statement. In Python 3 the print statement was changed to a print function. Try:

    print('[%d] %s%s %s' % (thread, indent, name, location))
    

    You can also use a newer way to format strings in Python 3:

    print('{:0d} {}{} {}'.format(thread, indent, name, location))