Learning embedded Python 

While embedding Python in an application may not seem that useful in some casses it can be very useful in others. Say you we’re working on a project in c/c++ and came across a feature that needed to be implemented, but this could not easily be done in c/c++ or if you wanted to add the ability for people to run their own scripts. in casses such as these the ability to embed Python can save a lot of time, effort and possibly money. Python allows you to do this using  its c API using c and c++ due to it’s compatibility with c to interact with code written in the Python language. While using the c API is not hugely difficult there are also some libraries that will make things slightly easier, you can find these using a quick Google search but be aware that ones such as boost python are more focused on extending Python than embedding it. Bellow is a list of tutorials that will help you get started.

official embedded Python documentation

Gives a lot of good information especially about compiling the application but is lacking in some areas

codeproject tutorial

Gives more information including using multiple threads and using classes but is a little outdated so some code will have to be convered to Python 3

linux journal article

Focused more on creating small projects but also a little outdated and will need to be converted to Python 3 Something I noticed was lacking from some of the tutorials is that it does not mention that the Python interpreter does not add the current directory to the python path automatically for you. This means that you will have to set it yourself once the interpreter is started this can be done using



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s