Embedding FreeCAD in a Python virtual environment
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 12
- Joined: Mon Sep 26, 2022 3:02 pm
Re: Embedding FreeCAD in a Python virtual environment
Its probably this!(see figure attached). I was wondering if it is possible to compile manually FreeCAD in such a way of having the Python version that I wish
- Attachments
-
- Screenshot 2022-09-29 092055.png (156.14 KiB) Viewed 577 times
-
- Posts: 12
- Joined: Mon Sep 26, 2022 3:02 pm
Re: Embedding FreeCAD in a Python virtual environment
I am not sure it is this problem, because since I have installed the Python 3.8, the problem persist
-
- Posts: 12
- Joined: Mon Sep 26, 2022 3:02 pm
Re: Embedding FreeCAD in a Python virtual environment
Guys!!! Its is now working. In windows it is needed to specify:
maybe we should add this detail in the wiki documentation
Code: Select all
import sys
PATH = 'C:\\Program Files\\FreeCAD 0.20\\bin'
sys.path.append(PATH)
from bin import FreeCAD
doc = FreeCAD.open('document.FCStd')
- Attachments
-
- bin.png (9.02 KiB) Viewed 537 times
-
- Posts: 12
- Joined: Mon Sep 26, 2022 3:02 pm
Re: Embedding FreeCAD in a Python virtual environment
mmm... not even this really works as it should. I am not sure that in windows the possibility of embedding FreeCAD is actually working.. i am loosing hopes
Re: Embedding FreeCAD in a Python virtual environment
I wonder what this line does:I am not sure that in windows the possibility of embedding FreeCAD is actually working.. i am losing hopes
Code: Select all
from bin import FreeCAD
Then the next statement (import Part) seems to cause a problem but you didn't post an error message. In order to troubleshoot the error you need the utility Dependency Walker (DW). Assuming you have unpacked the zip into C:\Temp you should add this line before import Part.
Code: Select all
import os
os.system("C:/Temp/depends.exe")
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Embedding FreeCAD in a Python virtual environment
try the conda version please: https://github.com/FreeCAD/FreeCAD-Bund ... tag/0.20.1
running python3.10 I had no trouble adding freecad to sys.path and then importing, didn't even need the add_dll_directory line
running python3.10 I had no trouble adding freecad to sys.path and then importing, didn't even need the add_dll_directory line