![]() However, one kink seems to be that the FreeCAD module needs to be imported before the Path module. ![]() Open Python Console in P圜harm and run command to check basic functioning import FreeCADĬreate python script with example functionality import FreeCADĪll FreeCAD functionality I have used in my scripts so far has worked. ~/Documents/freecad_appimage/squashfs-root/usr/libĪfter this P圜harm is busy indexing files for a while. Location: ~/Documents/pycharm_freecad_project/venvīase interpreter: ~/Documents/freecad_appimage/squashfs-root/usr/bin/pythonĪdd folder containing FreeCAD.so library as Content Root to P圜harm Project Structure and mark as Sources (by doing so, you shouldn't have to set PYTHONPATH or sys.path values, as P圜harm provides module location information to the interpreter) File: Settings: Project: Project Structure: Add Content Root ~/Downloads/./FreeCAD_*.AppImage -appimage-extractĬreate folder for P圜harm project mkdir -v ~/Documents/pycharm_freecad_projectĬreate pycharm project using Python interpreter from extracted AppImage Location: ~/Documents/pycharm_freecad_project ![]() Make AppImage executable chmod -v +x ~/Downloads/FreeCAD_*.AppImageĬreate folder for extracting AppImage mkdir -v ~/Documents/freecad_appimageĮxtract AppImage from folder (note: this expands to close to 30000 files requiring in excess of 2 GB disk space) cd ~/Documents/freecad_appimage This is what I did to get FreeCAD to work with P圜harm and virtualenv: In the end, I looked into the contents of the FreeCAD AppImage, and that turned out to have everything needed in a folder structure that appears to be very friendly to what P圜harm and Python expects from modules and libraries. I just couldn't make it work out, presumably due to how the included libraries are located and difficulty identifying an executable for the included Python interpreter. This means that the idea of grabbing FreeCAD modules and libraries it depends on from a Flatpak installation is in theory not horrible, as all parts are built together using the same library versions. The problem with piecing dependencies together is that for that approach to work out, everything from the FreeCAD and its dependencies to the Python interpreter and its dependencies seems to need to be built on the same versions of the libraries that they depend on to avoid causing segmentation faults that brings everything to a crashing halt. Other people's questions on FreeCAD forums went unanswered:įiguring this out was a great learning experience. Incude FreeCAD in system path for just one conda virtual environment Similar questions for Conda focus on importing libraries from the host system rather than embedding them in the virtual environment: Is it possible to embed Blender/Freecad in a python program? I came across a few prior questions which seemed to have similar intent, but no answers: I would appreciate either straight up instructions for how to do this or pointers to documentation that describes importing FreeCAD libraries in Python virtual environments, as I have not come across anything that specific yet. I seem to be looking at a very long chain of broken dependencies, even though I make the required libraries available and inform Python where they are located. ![]() This leads to a dead end when an import fails because it does not define a module export function according to Python: ImportError: dynamic module does not define module export function (PyInit_libnghttp2) When importing these dependencies explicitly, each of them have the same issue. In both cases the virtual environment detects where FreeCAD.so is located, but fails to find any of its dependencies, even when located in the same folder. In another attempt, I copied the contents of a FreeCAD flatpak install, as it should contain all the libraries that FreeCAD depends on.Īfter placing the libraries to be imported in the virtual maching folder, I have pointed to them with () as well as P圜harm's Project Structure tool in various attempts. deb packages from Debian, taking care to get the correct versions required by each dependency. In one attempt, I downloaded and unpacked. I started out with FreeCAD documentation for embedding in scripts as a basis: I am working in P圜harm 2021.1.1 with Python 3.8 in virtualenv on Debian 10. I hope a Python virtual environment can make that possible. I would like to avoid using the FreeCAD GUI as well as being dependent on having FreeCAD installed on the system, when working with Python scripts that use FreeCAD libraries to create and modify 3D geometry. How do I setup a Python virtual environment with the FreeCAD library embedded as to enable import as a module into scripts?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |