Can't import FreeCAD in python. DLL load failed while importing FreeCAD: The parameter is incorrect.
Posted: 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."
Steps to reproduce:
create a virtual environment with python 3.8:
https://www.python.org/downloads/release/python-380/
import FreeCAD with the following script:
Run the above script with the python 3.8 of the virtual environment set to your interpreter.
The above script will result in the bug for at least versions 0.19 and 0.20 of FreeCAD(I've only tested those versions)
Steps to reproduce:
create a virtual environment with python 3.8:
https://www.python.org/downloads/release/python-380/
Code: Select all
py -m virtualenv -p="<installed python 3.8 exe location>" .virtenv
Code: Select all
FREECADPATH = '/program files/FreeCAD 0.20/bin' # path to your FreeCAD.so or FreeCAD.dll file
import sys
import os
sys.path.append(FREECADPATH)
#print(sys.version)
import FreeCAD
print("free cad is " + str(FreeCAD))
The above script will result in the bug for at least versions 0.19 and 0.20 of FreeCAD(I've only tested those versions)
Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)