Specify a Python module directory when calling it from C ++

When trying to import and execute a function in a Python module from a C ++ executable, how can I pass to the directory where the module is located as a command line argument?

+4
source share
1 answer

Python rewards PYTHONPATH an environment variable. This is PATH as a variable that defines the environment variable where Python loads the modules.

Inside the .py script PYTHONPATH you can access and update it using the sys.path variable.

If you can show more source code as you create the Python interpreter, you might be given a more useful answer.

+2
source

All Articles