Python scripting with FreeCAD 32 bit version

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
JaredWest
Posts: 2
Joined: Wed Oct 23, 2019 4:43 pm

Python scripting with FreeCAD 32 bit version

Post by JaredWest »

Hi everyone,

I've been using the python scripting feature with FreeCAD for win64, but recently had to switch to a win32 system. I installed FreeCAD for win32 and tried the same python scripting procedure I was using before but cannot get it to work. Here is the code snippet I've been using:

Code: Select all

######################################################################
FREECADPATH = 'C:\Program Files (x86)\FreeCAD 0.18\bin' # path to your FreeCAD.so or FreeCAD.dll file
import sys

sys.path.append(FREECADPATH)
 
import FreeCAD
import Part
import Sketcher
import Mesh
import Draft
from FreeCAD import Base
#######################################################
And here is the error I get:

"ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-fd1d67362861> in <module>
14 sys.path.append(FREECADPATH)
15
---> 16 import FreeCAD
17 import Part
18 import Sketcher

ModuleNotFoundError: No module named 'FreeCAD'"

My machine runs on windows 10. Please let me know if you have any ideas as to how to fix this, thanks!
Last edited by Kunda1 on Wed Oct 23, 2019 4:55 pm, edited 1 time in total.
Reason: put code within code tags
mario52
Veteran
Posts: 4697
Joined: Wed May 16, 2012 2:13 pm

Re: Python scripting with FreeCAD 32 bit version

Post by mario52 »

hi welcome

try directly on windows tools https://www.computerhope.com/issues/ch000549.htm

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
JaredWest
Posts: 2
Joined: Wed Oct 23, 2019 4:43 pm

Re: Python scripting with FreeCAD 32 bit version

Post by JaredWest »

Hi Mario,

Thank you for the suggestion! I tried this and did not have any luck. Any more ideas on how I might be able to solve this?

Thanks again,
Jared
mario52
Veteran
Posts: 4697
Joined: Wed May 16, 2012 2:13 pm

Re: Python scripting with FreeCAD 32 bit version

Post by mario52 »

hi

sorry I do not know

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Python scripting with FreeCAD 32 bit version

Post by openBrain »

Are you running your script from the Python interpreter embedded in FC installation ?
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Python scripting with FreeCAD 32 bit version

Post by sgrogan »

openBrain wrote: Tue Oct 29, 2019 6:39 pm Are you running your script from the Python interpreter embedded in FC installation ?
Good question, looks like no

Code: Select all

<ipython-input-2-fd1d67362861> in <module>
Maybe trying to import a 32 bit FreeCAD into 64 bit ipython?
"fight the good fight"
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Python scripting with FreeCAD 32 bit version

Post by openBrain »

sgrogan wrote: Tue Oct 29, 2019 11:12 pm

Code: Select all

<ipython-input-2-fd1d67362861> in <module>
Maybe trying to import a 32 bit FreeCAD into 64 bit ipython?
I missed that clue. :) I'm not expert but I read several times on the forum that there is very very few chances that importing FC correctly works in another interpreter than the embedded one. Even if both are 32 or 64 bits. ;)
galou_breizh
Posts: 437
Joined: Wed Sep 15, 2010 9:38 am

Re: Python scripting with FreeCAD 32 bit version

Post by galou_breizh »

JaredWest wrote: Wed Oct 23, 2019 4:52 pm

Code: Select all

######################################################################
FREECADPATH = 'C:\Program Files (x86)\FreeCAD 0.18\bin' # path to your FreeCAD.so or FreeCAD.dll file
Is this really the correct path to FreeCAD? I would rather expect rather `'C:\Program Files\FreeCAD 0.18\bin'` on a 32bit system.

Gaël
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Python scripting with FreeCAD 32 bit version

Post by wmayer »

Replace

Code: Select all

FREECADPATH = 'C:\Program Files (x86)\FreeCAD 0.18\bin'
with

Code: Select all

FREECADPATH = 'C:/Program Files (x86)/FreeCAD 0.18/bin'
Post Reply