Using an existing Python installation
Python for .NET is really cool! Here's something I found out while trying to get it to work with my existing Python 2.3 installation. The README says:
**Can I use it with my existing Python installation?**
Yes, at least on win32 systems. Just copy the files Python.Runtime.dll and CLR.dll from the PythonNet directory to the root directory of your python installation.
This answer comes with one caveat in my experience. For some reason you have to 'import CLR' before trying to import anything else from the .NET runtime. This isn't the case if I use the Python executable included in PythonNet-1.0-beta1.tgz, only if I use my existing Python installation. So this fails: from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SomeNamespace') import CLR.SomeNamespace as SomeNamespace But this works: import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SomeNamespace') import CLR.SomeNamespace as SomeNamespace Is it possible I'm doing something wrong (more than likely)? Is this a bug? Is this expected behavior? ZODB requires you to 'import ZODB' before you do certain things, so I wouldn't be surprised... ______________ mike P.S. I'm now playing around with the TrueVision3D game engine using Python, something that I couldn't really do until now. I'm happy I saw a link to this project from Daily Python-URL.
So this fails:
from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SomeNamespace') import CLR.SomeNamespace as SomeNamespace
But this works:
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SomeNamespace') import CLR.SomeNamespace as SomeNamespace
Hi Mike - yes, I've already got this one in the bug hopper for b2. It has to do with the trickery I'm using to install the import hook not being quite tricky enough when it happens in an already-running interpreter. Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
Hi Brian, Brian Lloyd wrote:
So this fails:
from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SomeNamespace') import CLR.SomeNamespace as SomeNamespace
But this works:
import CLR from CLR.System.Reflection import Assembly Assembly.LoadWithPartialName('SomeNamespace') import CLR.SomeNamespace as SomeNamespace
Hi Mike - yes, I've already got this one in the bug hopper for b2. It has to do with the trickery I'm using to install the import hook not being quite tricky enough when it happens in an already-running interpreter. I felt into this trap too. The bug is also in beta3. With the line import CLR on top everything is working well. Another point is that it was neccessary to copy the CLR.dll to PythonRoot\DLLs and not only to PythonRoot (as written in the README).
WinXP HOME SP1, Python 2.3.3, PythonNet 1.0 beta 3 HTH Andreas
participants (3)
-
Andreas Kaiser
-
Brian Lloyd
-
Mike Casaday