[Python.NET] calling Python via Python.Runtime DLL from IronPython

Denis Akhiyarov denis.akhiyarov at gmail.com
Thu Apr 28 10:43:40 EDT 2016


Actually I tried embedding cpython with pythonnet 2.1 in ironpython 2.7.5
and hit the same issue! The weird thing is that copy_reg is actually
importable in regular ironpython code.

According to FePy project, which developed this embedding technology, this
used to work with ironpython 2, which was released around 2008-2009. Since
then both Ironpython and pythonnet (Python.Runtime.DLL) seem to have gone
through significant changes.

Maybe someone can test with the old combination of both ironpython and
pythonnet running on .NET 2.0.

http://ironpython.codeplex.com/releases/view/8365
https://sourceforge.net/projects/pythonnet/files/pythonnet/pythonnet-1.0-rc2-py2.3-clr1.1/pythonnet-1.0-rc2-py2.3-clr1.1.exe


On Fri, Apr 22, 2016 at 9:41 AM, Tony Roberts <tony at pyxll.com> wrote:

> This problem could be caused by two different incompatible CPython
> interpreters being installed. Possibly it's a .pyc file generated from
> another version of Python is being imported (and failing to import).
>
> Can you check what python27.dll is being used? You should be able to see
> it in visual studio in the modules window, or with a tool like sysinternals
> process explorer. If that dll is one left over from an old install of
> Python try either removing it, or setting your PATH so the correct one is
> picked up.
>
> One other thing you might want to try is a fresh install of Python (making
> sure that no old python27.dll files are being used) as your pyc caches
> might be in a weird state if the problem is caused by conflicting Python
> installs.
>
> A quick check to see if it is something like that would be to delete
> copy_reg.pyc and see if it gets any further.
>
> Best regards,
> Tony
>
> On Fri, Apr 22, 2016 at 3:19 PM Denis Akhiyarov <denis.akhiyarov at gmail.com>
> wrote:
>
>> Are you able to run PythonEngine.Initialize() from c#, not ironpython?
>>
>>
>> On Thursday, April 21, 2016, Cameron Hayne <cameron.hayne at introspect.ca>
>> wrote:
>>
>>> I tried calling  Py_SetPythonHome("C:\\Python27")   before calling
>>> PythonEngine.Initialize(),  but I got the same problem (re ‘copy_reg’ not
>>> found).
>>> Any other suggestions?
>>> --
>>> Cameron Hayne
>>> cameron.hayne at introspect.ca
>>>
>>>
>>> On Apr 19, 2016, at 4:37 PM, Tony Roberts <tony at pyxll.com> wrote:
>>>
>>> > No need to import the c Python extension - from IronPython you would
>>> be able to reference the Python.runtime assembly without it. The problem
>>> you're having sounds like the python path isn't correct for cPython. You
>>> could try setting the PYTHONHOME environment variable and see if that gets
>>> you any further.
>>> >
>>> > Best regards,
>>> > Tony
>>> > On Tue, Apr 19, 2016 at 9:30 PM Denis Akhiyarov <
>>> denis.akhiyarov at gmail.com> wrote:
>>> > Did you try this code?
>>> >
>>> > http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
>>> >
>>> > On Tue, Apr 19, 2016 at 2:09 PM, Cameron Hayne <
>>> cameron.hayne at introspect.ca> wrote:
>>> > Should it be possible to call Python (CPython) code from IronPython
>>> (an IronPython script) via the Python.Runtime DLL ?
>>> > I.e. an IronPython script that imports the Python.Runtime DLL and then
>>> calls the functions provided by that DLL.
>>> > In my preliminary tests, I get an error about ‘copy_reg’ not being
>>> found. This error seems to happen when calling PythonEngine.Initialize().
>>>
>>>
>>>
>>>
>>>
>>> _________________________________________________
>>> Python.NET mailing list - PythonDotNet at python.org
>>> https://mail.python.org/mailman/listinfo/pythondotnet
>>>
>> _________________________________________________
>> Python.NET mailing list - PythonDotNet at python.org
>> https://mail.python.org/mailman/listinfo/pythondotnet
>
>
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> https://mail.python.org/mailman/listinfo/pythondotnet
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20160428/73b50560/attachment.html>


More information about the PythonDotNet mailing list