From mathedotnet at gmail.com Mon Oct 10 08:46:02 2011 From: mathedotnet at gmail.com (MATHE MANOJ) Date: Mon, 10 Oct 2011 12:16:02 +0530 Subject: [Python.NET] Adding Methods dynamically Message-ID: Hello Can anyone help me in adding methods to python dynamically, as we do for add contants.( C# ) PyDict_SetItemString(d, "pi", tmp); Thank you * * *Manoj * -------------- next part -------------- An HTML attachment was scrubbed... URL: From mathedotnet at gmail.com Thu Oct 13 17:43:49 2011 From: mathedotnet at gmail.com (MATHE MANOJ) Date: Thu, 13 Oct 2011 21:13:49 +0530 Subject: [Python.NET] Problem in PyEval_EvalCode Message-ID: Hi All I am trying to embedded python with C# I need to execute commands like this *print math.sin(90)* I am writing my code in C# using wrapper classes. I wrote my code like this public void TestCommandFileExecution(string code) { IntPtr modulePtr = Runtime.PyImport_ImportModule("math"); IntPtr appPtr = Runtime.PyEval_GetBuiltins(); IntPtr srcCompilation = Runtime.Py_CompileString(code, "", Runtime.Py_single_input); IntPtr execution = ExtendedRuntime.PyEval_EvalCode(srcCompilation, appPtr, IntPtr.Zero); Runtime.PyErr_Print(); } And I am sending a code like this CommandFileExecution("print 'test!'"); // Working fine CommandFileExecution("print math.sin(90)"); // Showing a error like this. *Traceback :* * File??, line 1,in * *NameError: name ?math? is not defined* * * Please help me Thank you Manoj -------------- next part -------------- An HTML attachment was scrubbed... URL: From max at slimmersoft.com Fri Oct 28 19:33:27 2011 From: max at slimmersoft.com (Max Slimmer) Date: Fri, 28 Oct 2011 10:33:27 -0700 Subject: [Python.NET] How to install .net-awareness into existing windows python Message-ID: I am running python 2.6 and would like to use python for .net. I have downloaded pythonnet-2.0-alpha2-136-py26.zip and then copied the clr.pdl to my python DLLs directory upon trying to "import clr" I get ImportError: dynamic module does not define init function (initclr). Ultimately I want to include some code to access .net packages in my application using py2exe. Any help thanks max -------------- next part -------------- An HTML attachment was scrubbed... URL: From 1989lzhh at gmail.com Sat Oct 29 12:30:05 2011 From: 1989lzhh at gmail.com (=?GB2312?B?wfXV8bqj?=) Date: Sat, 29 Oct 2011 18:30:05 +0800 Subject: [Python.NET] How to install .net-awareness into existing windows Message-ID: Hi, you should copy both the clr.pyd and Python.Runtime.dll to the path which contents in sys.path like your current work directory and so on. Hope it will help Regards, Liu Zhenhai -------------- next part -------------- An HTML attachment was scrubbed... URL: From max at slimmersoft.com Sun Oct 30 02:55:14 2011 From: max at slimmersoft.com (Max Slimmer) Date: Sat, 29 Oct 2011 18:55:14 -0700 Subject: [Python.NET] How to install .net-awareness into existing windows In-Reply-To: References: Message-ID: I had tried this and did so again, it makes no difference. My observation indicates that Python.Runtime.dll is used when running from mono I may be wrong there. import of clr returns error indicating initclr is missing, my understanding is this should be in the module and is needed for c extentions. I am running from windows not mono and don't see even how Python.Runtime could be called the name implies a package so it might be possible to import with __import__() but that doesn't sound right to me. Regardless that doesn't make any difference I still get the same import error. Help! Max Slimmer eMail: max at SlimmerSoft.com phone: 707 703-4396 On Sat, Oct 29, 2011 at 3:30 AM, ??? <1989lzhh at gmail.com> wrote: > Hi, > you should copy both the clr.pyd and Python.Runtime.dll to the path which > contents in sys.path > like your current work directory and so on. > Hope it will help > > Regards, > Liu Zhenhai > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max at slimmersoft.com Fri Oct 28 05:16:02 2011 From: max at slimmersoft.com (Max Slimmer) Date: Thu, 27 Oct 2011 20:16:02 -0700 Subject: [Python.NET] installing pythondotnet in existing python under windows Message-ID: I am running python 2.6 under windows and would like to access some .net code. I have downloaded pythonnet-2.0-alpha2-136-py26.zip from source-forge. I can run the python.exe in \python2.6-UCS2 folder and from there import clr, however I want to import and run from my existing python2.6 installation. I put the clr.pyd file in sitepackages and also in DLLs but when I get the following: Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import clr Traceback (most recent call last): File "", line 1, in ImportError: dynamic module does not define init function (initclr) >>> I also could use a bit more documentation, I went to Bryan Lloyd's blog and see: Refactored import syntax: now you can use un-prefixed namespace names ( "from System import *") instead of the old "magic CLR module" syntax ("from CLR.System...). The old "CLR." syntax is still supported until 3.0, but now officially deprecated. This was the main compatibility problem with code targeted for IP. I can't figure how to get here! what is the difference between the -UCS2 and -UCS4 folders? -------------- next part -------------- An HTML attachment was scrubbed... URL: From brad at fie.us Sun Oct 30 18:47:49 2011 From: brad at fie.us (Bradley Friedman) Date: Sun, 30 Oct 2011 13:47:49 -0400 Subject: [Python.NET] installing pythondotnet in existing python under windows In-Reply-To: References: Message-ID: CPython is compiled with one of two unicode modes. The symbols in the dynamic library are different based on that original configuration flag. Basically that config flag on python makes versions of python that are binary incompatible with one another even though they are the same version. Native python extensions that link against python, need to therefore be linked against one or the other. You can't link against both simultaneously. Since most CPython native extensions are either pre built for a linux distribution (under the control of a managed package system), or are built on the target system itself, this is not an issue. They know which flags were used by the python on the system. In windows land, which is primarily a binary distribution land in which there is no cohesive binary package system managing the dependencies, your only real choice for binary distributions is to build both and provide them both. If you try to run a mismatched binary with python, it will error out at runtime saying it can't find symbols, or entry points. This would potentially look much like the error you post. Though I would expect to see a more specific error info. But at its base level, it would have trouble finding the function it was looking for, due to the function being fundamentally different in the data type of the parameters. The symbol it was looking for would not be found. Though there could be a myriad of other reasons why its having trouble finding that symbol. On Oct 27, 2011, at 11:16 PM, Max Slimmer wrote: > I am running python 2.6 under windows and would like to access some .net code. I have downloaded pythonnet-2.0-alpha2-136-py26.zip from source-forge. > I can run the python.exe in \python2.6-UCS2 folder and from there import clr, however I want to import and run from my existing python2.6 installation. I put the clr.pyd file in sitepackages and also in DLLs but when I get the following: > > Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import clr > Traceback (most recent call last): > File "", line 1, in > ImportError: dynamic module does not define init function (initclr) > >>> > > I also could use a bit more documentation, I went to Bryan Lloyd's blog and see: > Refactored import syntax: now you can use un-prefixed namespace names ( "from System import *") instead of the old "magic CLR module" syntax ("from CLR.System...). The old "CLR." syntax is still supported until 3.0, but now officially deprecated. This was the main compatibility problem with code targeted for IP. > > I can't figure how to get here! > > what is the difference between the -UCS2 and -UCS4 folders? > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------- next part -------------- An HTML attachment was scrubbed... URL: From max at slimmersoft.com Sun Oct 30 21:23:00 2011 From: max at slimmersoft.com (Max Slimmer) Date: Sun, 30 Oct 2011 13:23:00 -0700 Subject: [Python.NET] installing pythondotnet in existing python under windows In-Reply-To: References: Message-ID: I tried using the clr.pyd from both python1.6-UCS2 and python2.6-UCS4 folders, same results. I am running the current python windows build: Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Has anyone built clr.pyd for this distribution. I am not that familiar with latest ms Visual Studio etc. Looking at src/ in svn I see mostly .cs files, I would really like to be able to import clr then clr.AddReferenct(somefile) # instantiat python object from somefile xx = somefile.someobject() ...etc... I can do this using the python.exe found in the python2.6-UCS2 folder, but I want to use my regular python that has numerous packages and where I build a product with py2exe... What are my options, must I use the python distributed with pythonDotNet, and if so what are the repercussions when trying to use other packages. I see that if I run the python .exe that it gets my installed .site information and therefore has access to all my libraries. What has been done to this python.exe and can I simply move it to my python26/ directory? It feels very strange to override the python.exe in the standard distribution, what about things built with py2exe will they still work? Any enlightenment would be much appreciated. max Max Slimmer eMail: max at SlimmerSoft.com phone: 707 703-4396 On Sun, Oct 30, 2011 at 10:47 AM, Bradley Friedman wrote: > CPython is compiled with one of two unicode modes. The symbols in the > dynamic library are different based on that original configuration flag. > Basically that config flag on python makes versions of python that are > binary incompatible with one another even though they are the same version. > Native python extensions that link against python, need to therefore be > linked against one or the other. You can't link against both > simultaneously. > > Since most CPython native extensions are either pre built for a linux > distribution (under the control of a managed package system), or are built > on the target system itself, this is not an issue. They know which flags > were used by the python on the system. In windows land, which is primarily > a binary distribution land in which there is no cohesive binary package > system managing the dependencies, your only real choice for binary > distributions is to build both and provide them both. > > If you try to run a mismatched binary with python, it will error out at > runtime saying it can't find symbols, or entry points. This would > potentially look much like the error you post. Though I would expect to > see a more specific error info. But at its base level, it would have > trouble finding the function it was looking for, due to the function being > fundamentally different in the data type of the parameters. The symbol it > was looking for would not be found. > > Though there could be a myriad of other reasons why its having trouble > finding that symbol. > > On Oct 27, 2011, at 11:16 PM, Max Slimmer wrote: > > I am running python 2.6 under windows and would like to access some .net > code. I have downloaded pythonnet-2.0-alpha2-136-py26.zip from > source-forge. > I can run the python.exe in \python2.6-UCS2 folder and from there import > clr, however I want to import and run from my existing python2.6 > installation. I put the clr.pyd file in sitepackages and also in DLLs but > when I get the following: > > Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit > (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import clr > Traceback (most recent call last): > File "", line 1, in > ImportError: dynamic module does not define init function (initclr) > >>> > > I also could use a bit more documentation, I went to Bryan Lloyd's blog > and see: > Refactored import syntax: now you can use un-prefixed namespace names ( > "from System import *") instead of the old "magic CLR module" syntax ("from > CLR.System...). The old "CLR." syntax is still supported until 3.0, but now > officially deprecated. This was the main compatibility problem with code > targeted for IP. > > I can't figure how to get here! > > what is the difference between the -UCS2 and -UCS4 folders? > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: