FreeCAD-Bundle icon indicating copy to clipboard operation
FreeCAD-Bundle copied to clipboard

FreeCAD breaks Python

Open ei14 opened this issue 1 year ago • 2 comments

I use FreeCAD. I also program in Python. In my case, these are separate things, never mixed. Yet when I run help("modules") in a Python environment, Python crashes. I determined this is because import freecad causes a crash.

I do not want to use FreeCAD functionality in any of my Python programs. But I also do not want to uninstall the entirety of FreeCAD just in order to use the offline Python documentation reader pydoc. FreeCAD should not break my coding environment! It's a CAD software! What gives?

Frankly, why does FreeCAD even pollute python3.XX/site-packages to begin with? It's a GUI software that, from a user perspective, should have nothing to do with Python programming as far as I know.

Here is the Python output of import freecad:

Python 3.12.3 (main, Apr 23 2024, 09:16:07) [GCC 13.2.1 20240417] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import freecad
PATH_TO_FREECAD_LIBDIR not specified, using default FreeCAD version in /usr/lib/freecad/lib
Fatal Python error: PyImport_AppendInittab: PyImport_AppendInittab() may not be called after Py_Initialize()
Python runtime state: initialized

Current thread 0x00007934b9e72b80 (most recent call first):
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1289 in create_module
  File "<frozen importlib._bootstrap>", line 813 in module_from_spec
  File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "/usr/lib/python3.12/site-packages/freecad/__init__.py", line 20 in <module>
  File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 995 in exec_module
  File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
  File "<stdin>", line 1 in <module>
Aborted (core dumped) 

I am not knowledgeable enough to interpret this output.

ei14 avatar May 11 '24 01:05 ei14