Home | News | Documentation | Download

TPython usage:: how to import and use the module?

I’m trying to run in C++ a function declared in a python module but it’s not clear to me how can i access the imported module …
Ideally i would like to be able to do:

    from alienpy import alien
except Exception as e:
        from xjalienfs import alien
    except Exception as e:
        print("Can't load alienpy, exiting...")

or at least

import alienpy.alien as alien

so far i could do only this:

root [0] auto import_status = TPython::Import("alienpy");
root [1] cout << import_status << endl;

but i did not found a documentation about how to continue from this point …
Thanks a lot!


In order to import a module with TPython, please make sure the module is in the PYTHONPATH and then run TPython::Exec("import alienpy").

Thanks! Indeed the exec worked and then also with exec i can access the module.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.