Repository navigation
Embedded Python
Fabian Wein edited this page Feb 17, 2023
·
3 revisions
Embedding a Python interpreter within openCFS is triggered via
See the presentation for detailed introduction for developers cfs_python.pdf
- enable USE_EMBEDDED_PYTHON to build
- cmake has a strange logic to select a Python instance. In case use something like
set(PYTHON_INCLUDE_DIR "/Users/fwein/.pyenv/versions/3.8.1/include/python3.8")
set(PYTHON_LIBRARY "/Users/fwein/.pyenv/versions/3.8.1/lib/libpython3.8.a")
- test via
ctest -R python
- For Windows it is a good idea to use Anaconda.
- If
pythoncomplains about missing activation, call e.g.c:\ProgramData\Anaconda3\Scripts\activate base - If embedded python fails with error below, the reason could be a non-existing
c:\ProgramData\Anaconda3\python39.zipinsys.path. Fix it by creating a file of that name (content does not matter, e.g. a text file with 'conda installation is poor´.
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\fwein\\code\\master\\release_ninja\\bin\\cfstest.exe'
sys.base_prefix = 'c:\\ProgramData\\Anaconda3'
sys.base_exec_prefix = 'c:\\ProgramData\\Anaconda3'
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\fwein\\code\\master\\release_ninja\\bin\\cfstest.exe'
sys.prefix = 'c:\\ProgramData\\Anaconda3'
sys.exec_prefix = 'c:\\ProgramData\\Anaconda3'
sys.path = [
'c:\\ProgramData\\Anaconda3\\python39.zip',
'.\\DLLs',
'.\\lib',
'C:\\Users\\fwein\\code\\master\\release_ninja\\bin',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'