command line – How to `import FreeCAD` in CLI (python)

How can I import FreeCAD from the python console?

I’m trying to write a script that can manipulate a given FreeCAD file, but I can’t even get FreeCAD imported into the python console on a system where FreeCAD is installed.

user@disp7637:~$ sudo dpkg -l | grep -i freecad
ii  freecad                                       0.19.1+dfsg1-2+deb11u1             all          Extensible Open Source CAx program
ii  freecad-common                                0.19.1+dfsg1-2+deb11u1             all          Extensible Open Source CAx program - common files
ii  freecad-python3                               0.19.1+dfsg1-2+deb11u1             amd64        Extensible Open Source CAx program - Python 3 binaries
ii  libfreecad-python3-0.19                       0.19.1+dfsg1-2+deb11u1             amd64        Extensible Open Source CAx program - Python 3 library files
user@disp7637:~$ 
user@disp7637:~$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import FreeCAD
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'FreeCAD'
>>> import freecad
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'freecad'
>>> 

How can I import FreeCAD in the python console?

Read more here: Source link