0

I have an application that provides a nice Python API (Python3, FWIW). Using its GUI I can trigger Python scripts or use its Python shell. In the scripts I have it run, I can import the Foo module the vendor provides. What I'd like to do is import Foo from a stand-alone Python session. Is this possible? (Or does it depend on how it's implemented?)

I looked at sys.path in the interactive shell they provide but don't see anything relevant.

When the application spawns a Python interpreter, is it somehow injecting a module into it that can't be accessed from a stand-alone Python interpreter or is there a way to tell my Python interpreter to find Foo inside the application's executable?

For what it's worth:

>>> Foo
<module 'Foo' (built-in)>
>>>
0

1 Answer 1

2

There's no guarantee that the module available within the application could be imported into a standalone script, especially if the API provides facilities for interacting with the running application. It's likely to be something that's provided by the way the Python interpreter is embedded in the application. See the documentation on embedding Python for how that might be done.

That said, it would be worth looking to see whether you can find a .pyd file (on Windows) or a .so file (on Unices) for the module somewhere in the application's files - it's possible that some of the functionality it provides could work without the running app.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.