[Python.NET] PythonHome property referencing Python folder

Christopher Fraschetti chris.fraschetti at houghton.edu
Tue Apr 1 18:04:41 CEST 2008

I am attempting to package Python with a .Net application and would like 
to run the packaged version of python that I have using Python for 
.Net.  In other words, python will not be officially installed on the 
client but will be reference with the .Net package.

Is there a way to set PythonEngine to use a specific location for 
PythonHome.  It seems obvious that the Python.Engine.PythonHome property 
(Read/Write property) could be written with the folder containing the 
Python folder I would like to use but when I try writing the property, 
initializing the engine and then read the PythonHome it says the 
property contains "-4z".  Also... it does not work.  After 
initialization I try to import a module and it returns a null value.

Here is some code:
PythonEngine.PythonHome = "c:\\Python25"; //Not officially installed.  
Just a folder containing a python implementation.
PyObject appModule = PythonEngine.ImportModule("app"); //app.py found in 
root folder of .Net application
PyObject startApplication = appModule.GetAttr("startApplication");
PyObject app = startApplication.Invoke()

This does work with an officially installed version of Python (barring 
the change in PythonHome) but does not work just putting the Python25 
folder in the given location and referencing it with the PythonHome 

So, is this the correct use of the property?
Is there any way to accomplish what I am attempting to do?

Thanks in advance for any insight.


More information about the PythonDotNet mailing list