Can't import FreeCAD in python. DLL load failed while importing FreeCAD: The parameter is incorrect.

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: BUG: Can't import FreeCAD in python. DLL load failed while importing FreeCAD: The parameter is incorrect.

Post by heda »

well, when you select an interpreter you get exactly that, a standalone interpreter session, which unless you go through some hoops is never going to be the same (process) as the one that is in the fc session you started in the "regular way" - that is sort of what a remote connecting session does for you... (your finding is analogue to starting 2 gui sessions and expecting that a single document can be edited in one and automatically & immediately changes are reflected in the other - which for the record will never be the case...)

hm, all fc's i come across have pip bundled, in any case there is always https://docs.python.org/3/library/ensurepip.html
edwilliams16
Veteran
Posts: 3179
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: BUG: Can't import FreeCAD in python. DLL load failed while importing FreeCAD: The parameter is incorrect.

Post by edwilliams16 »

ryn wrote: Mon Jun 20, 2022 8:14 pm

a/b) Im using VS-CODE but selecting the interpreter to be FreeCAD's python works inside the interpreter. However, it doesn't detect objects inside FreeCAD, I.E: if there is an active document, FreeCAD.listDocuments() wont see it when running FreeCAD's python via VSCode. I also couldn't manage to get pip to work with FreeCAD as a whole either. FreeCAD doesn't come installed with pip, and I ran into error after error trying to get FreeCAD's python to have it.
I've been working on again this recently, and I still haven't been able to get intellisense/code completion working in the VSCode editor.

However, in my Mac version I can get pip to work with

Code: Select all

/path/to/FreeCAD's/python -m pip install package
in particular I use it to get ptvsd for the debugger

Code: Select all

/Applications/FreeCAD.app/Contents/Resources/bin/python -m pip install ptvsd
I had no luck with debugpy, the replacement for the deprecated ptvsd It just crashes with a missing import of its own.

In a debug session I have full access to FreeCAD's namespace etc. and can dive on all the variables and the debug console does has code completion. The editor however is ignorant.
One might as well just use FreeCAD's python console to explore its python interface.
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: BUG: Can't import FreeCAD in python. DLL load failed while importing FreeCAD: The parameter is incorrect.

Post by onekk »

ryn wrote: Thu Jun 16, 2022 5:46 pm BUG: When attempting to import FreeCAD in python, I get the error, "ImportError: DLL load failed while importing FreeCAD: The parameter is incorrect."
As it is not a BUG, as FC is not intended to be used as a Python Module, could you please delete the BUG word in the title.

simply edit your first post title and modify the title.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply