[Python.NET] embedding in aspx problem

Brian Lloyd brian at zope.com
Mon May 17 10:17:30 EDT 2004


Hi Laurian,

Try removing the call to PythonEngine.Finalize(). That should 
_only_ be called when you are truly finished with the Python 
interpreter (to clean up and free resources, etc.) That method 
tears down the Python runtime environment and after it is called 
you can't use Python anymore from any thread in the process.

- Brian

> I'm trying to figure out how can I use Python.NET, and I'm having weird
> problems:
> 
> This run ok:
> 
> <script language="C#" runat="server">
> void Page_Load(Object sender, EventArgs e) {
> 
>   PythonEngine.Initialize();
>     
>      PyObject p = PythonEngine.ImportModule("sys");
>      PyObject c = p.GetAttr("path");
>      
> 
>      string s = c.ToString();
>      Response.Write(s);
> 
>      
>      PythonEngine.Finalize();
> }
> 
> </script>
> 
> It outputs:
> ['D:\\testsite\\bin\\python23.zip', '.\\DLLs', '.\\lib',
> '.\\lib\\plat-win', '.\\lib\\lib-tk',
> '\\\\?\\C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322']
> 
> But when I'm trying to run the script foo.py which is located under the
> above '\lib' I'm getting "Exception of type
> Python.Runtime.PythonException was thrown." at the line:
> 
> PyObject p = PythonEngine.ImportModule("foo");
> 
> How can I learn more about the exception cause?
> 
> Thank you,
> -- 
> Laurian Gridinoc
> Chief Developer
> GRAPEFRUIT DESIGN
> www.grapefruitdesign.com
> 
> 
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet
> 


Brian Lloyd        brian at zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com 





More information about the PythonDotNet mailing list