Hi,
Can anyone tell me how to edit python path of FreeCAD python interpreter?
As I run
import sys
sys.path
Both in system's python interpreter and FreeCAD interpreter and I got different results. Since I was trying too use a python library which could not be found by FreeCAD's interpreter (But it works well in system's interpreter), I wonder if there is anyway to edit the path of FreeCAD's python interpreter.
Thanks!
Add extra python lib path to FreeCAD system path
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Add extra python lib path to FreeCAD system path
yes, you can add other paths to sys.path, simply like this:
Code: Select all
import sys
sys.path.append("/path/to/my/other/libs")
Re: Add extra python lib path to FreeCAD system path
Hi, yorik,yorik wrote:yes, you can add other paths to sys.path, simply like this:Code: Select all
import sys sys.path.append("/path/to/my/other/libs")
I just did, in FreeCAD interpreter, and it seems that the path has been added as well (By printing everything)
It is actually the ros python library, The weird thing is, when I added the path, and try to import the lib in interpreter under FreeCAD Gui , it reports no error, which means FreeCAD is able to locate the lib. But when I running my code (written in C++ but it should be calling that python lib), the console reports an ImportError: No module named catkin.find_in_workspaces. Is there any way that I can add the path to FreeCAD's interpreter at initial states?
Re: Add extra python lib path to FreeCAD system path
Hm I have no idea... Isn't it possible to modify the sys.path from your C++ code too, before doing the import?