Discussion:
[Python.NET] How to embed properly using Python for .NET
Denis Akhiyarov
2014-08-03 04:50:52 UTC
Permalink
When I try to use

PythonEngine.ImportModule(mymodulename)

some of the optional modules in dependencies are attempted to be loaded
(not required for module use without embedding). This results in return
null from this method because some of these optional dependencies are not
required and hence not available. What is the proper method to use in this
PythonNET API for loading user-written module which depends on multiple
other modules?

I tried importhook.cs from both versions:

https://github.com/pythonnet/pythonnet

https://github.com/renshawbay/pythonnet


http://stackoverflow.com/questions/25101718/how-to-embed-properly-using-python-for-net
Mika S
2014-08-04 18:11:14 UTC
Permalink
What dependencies are missing?
I find that having a basic python installation on the target machine is
necessary. If that's not the case then copy your python folder with the
modules and they eggs on the target machine and set the PYTHONPATH
environment var from c#.
Post by Denis Akhiyarov
When I try to use
PythonEngine.ImportModule(mymodulename)
some of the optional modules in dependencies are attempted to be loaded
(not required for module use without embedding). This results in return
null from this method because some of these optional dependencies are not
required and hence not available. What is the proper method to use in this
PythonNET API for loading user-written module which depends on multiple
other modules?
https://github.com/pythonnet/pythonnet
https://github.com/renshawbay/pythonnet
http://stackoverflow.com/questions/25101718/how-to-embed-properly-using-python-for-net
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Denis Akhiyarov
2014-10-06 13:53:50 UTC
Permalink
here is a related SO question: http://stackoverflow.com/questions/25101718
It turned out that PTVS was stepping through the use-handled exceptions
for module imports, so the problem was not here.
The original problem is that when importing modules as .py* files, then it
fails. The only way it works is when the module is setup as a package with
corresponding __init__.py file(s) in the subfolder(s).
Let me know if anyone else can reproduce this issue?
Post by Mika S
What dependencies are missing?
I find that having a basic python installation on the target machine is
necessary. If that's not the case then copy your python folder with the
modules and they eggs on the target machine and set the PYTHONPATH
environment var from c#.
On Sat, Aug 2, 2014 at 9:50 PM, Denis Akhiyarov <
Post by Denis Akhiyarov
When I try to use
PythonEngine.ImportModule(mymodulename)
some of the optional modules in dependencies are attempted to be loaded
(not required for module use without embedding). This results in return
null from this method because some of these optional dependencies are not
required and hence not available. What is the proper method to use in this
PythonNET API for loading user-written module which depends on multiple
other modules?
https://github.com/pythonnet/pythonnet
https://github.com/renshawbay/pythonnet
http://stackoverflow.com/questions/25101718/how-to-embed-properly-using-python-for-net
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Denis Akhiyarov
2014-10-06 13:51:56 UTC
Permalink
It turned out that PTVS was stepping through the use-handled exceptions for
module imports, so the problem was not here.

The original problem is that when importing modules as .py* files, then it
fails. The only way it works is when the module is setup as a package with
corresponding __init__.py file(s) in the subfolder(s).

Let me know if anyone else can reproduce this issue?
Post by Mika S
What dependencies are missing?
I find that having a basic python installation on the target machine is
necessary. If that's not the case then copy your python folder with the
modules and they eggs on the target machine and set the PYTHONPATH
environment var from c#.
Post by Denis Akhiyarov
When I try to use
PythonEngine.ImportModule(mymodulename)
some of the optional modules in dependencies are attempted to be loaded
(not required for module use without embedding). This results in return
null from this method because some of these optional dependencies are not
required and hence not available. What is the proper method to use in this
PythonNET API for loading user-written module which depends on multiple
other modules?
https://github.com/pythonnet/pythonnet
https://github.com/renshawbay/pythonnet
http://stackoverflow.com/questions/25101718/how-to-embed-properly-using-python-for-net
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
https://mail.python.org/mailman/listinfo/pythondotnet
Loading...