Import FreeCAD in Python

If you’ve compiled FreeCAD, but don’t know how to import it as a package in Python then read on.

First of all, you need to locate where the file is.


Mine is in /home/mandeep/Desktop/build/lib.

To be able to do:

import FreeCAD

You’ll have to go to that directory and run python and if you now try to import, it will work. But most probably, you won’t agree to use it as it might feel impractical.

Another method is to append this path to sys.path. For this, you need to edit a file

For example,


The would probably be where your python lib directory is. It may probably look like: /usr/lib/python2.7. But I am using the Python within the virtualenv so the python lib is within the virtualenv e.g. venv/lib/python2.7. Here venv is my virtualenv.

Read more about this at

The idea to edit the file is that it gets initialized with Python. So you can now import your packages from anywhere.