If embedding Pygame to C++ to have a game be an executable, is there any extra process I would have to use in order to use Pygame functions when embedding into C++? As opposed to just writing embedding code in C++ for normal Python code?

To clear cut the question I want to know if it's the same process without having to call different functions.

EDIT: My question is if I have to call different functions in C++ when embedding Python code that uses Pygame modules. I am NOT using pygame2exe nor py2exe. I never even mentioned those. My question is solely about code embedding.

  • \$\begingroup\$ I don't understand what you're asking exactly. Are you wondering if you need to change Python function calls when using Pygame2exe? Please clarify your question. \$\endgroup\$ Commented Oct 14, 2012 at 21:08
  • \$\begingroup\$ Oh god that circularity... Anyway, I highly doubt this has anything to do with game development. If you're looking for a way to compile Python code, @LaurentCouvidou has your answer. \$\endgroup\$
    – jcora
    Commented Oct 14, 2012 at 21:18
  • \$\begingroup\$ Why are you trying to embed Python with Pygame into C++? Just use SDL, since that's what Pygame is built on. Pygame is supposed to be the boss of the application. You can write C++ modules that are loaded from Python, but if you try to embed Python and scripts that depend on Pygame, you're gonna have a bad time. \$\endgroup\$ Commented Oct 15, 2012 at 1:29
  • \$\begingroup\$ I would like to see this question reopened and an answer from @michael.bartnett giving some details about the pitfalls of such an approach. If I wanted to use Python for 'scripting' inside of a game that's already mostly written in C++, would this not be the way to go? \$\endgroup\$
    – tugs
    Commented Oct 15, 2012 at 19:47
  • \$\begingroup\$ @tugs I don't think I could add much more useful information than what's already out there: 0, 1, 2, 3 \$\endgroup\$ Commented Oct 15, 2012 at 23:04

1 Answer 1


When you embed Python into C++, you just have to set up the code to call the Python functions in C++. The Python libraries that you use, such as Pygame, have no effect on the C++ binding code you need to use.


Not the answer you're looking for? Browse other questions tagged .