Skip to content

PythonEngine.Initialize() error #448

Closed

Description

@jwlc76

Environment

  • Pythonnet version:2.4
  • Python version:2.7.13 32bit
  • Operating System: Win7 sp1 64bit

Details

Pythonnet compiled under VS2015. Demo packages work fine (wordpad.py etc) but I get an error trying to call python from .net using the Python.Runtime.dll.

When calling PythonEngine.Initialize(); the following error occurs in runtime.cs Line 188.

"A call to PInvoke function 'Python.Runtime!Python.Runtime.Runtime::PyDict_GetItemString' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."

I have confirmed that the version being compiled is for windows 32bit and Python 2.7. Any suggestion much appreciated.

Activity

  1. filmor commented on Mar 31, 2017

    @filmor
    Member

    Which version (i.e. commit) are you using exactly? Can you bisect the error?

  2. jwlc76 commented on Mar 31, 2017

    @jwlc76
    Author

    Tested with the latest commit as of a the 31-01-2017. I will try and replicate with an earlier version.

  3. jwlc76 commented on Mar 31, 2017

    @jwlc76
    Author

    The issues first occurs in c7b4c21 (commit on the 1 march 2017)

  4. den-run-ai commented on Mar 31, 2017

    @den-run-ai
    Contributor

    @jwlc76 thank you for reporting this issue!

    @vmuriart do you see anything suspicious in that commit? It looks like only refactoring to me.

  5. jwlc76 commented on Mar 31, 2017

    @jwlc76
    Author

    OK Ive checked further and Ive traced it to f1aa89b (sorry I was incorrect earlier).
    The issue is the removal of the calling convention in [DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl)].

    When googleing the error message earlier this is one of the thing that came up as a possible cause. So looks like this is the problem. Adding the CallingConvention back in on the latest commit should resolve the issue.

  6. den-run-ai commented on Mar 31, 2017

    @den-run-ai
    Contributor

    @vmuriart well, I did mention this before, not sure why you ended up removing calling convention anyway?

    #403 (comment)

  7. jwlc76 commented on Mar 31, 2017

    @jwlc76
    Author

    Just to confirm adding back in the CallingConvention to the DllImports in runtime.cs on the master commit works for me.

  8. den-run-ai commented on Mar 31, 2017

    @den-run-ai
    Contributor

    @jwlc76 feel free to submit a pull request to add cdecl back! Let us know, thanks again.

  9. vmuriart commented on Mar 31, 2017

    @vmuriart
    Contributor

    The issue was with some of the other arguments (especially charset). I'll take care of re-adding the callingconv this weekend.

  10. added a commit that references this issue on Apr 2, 2017
    67650a2
  11. added a commit that references this issue on Jun 1, 2017
    1aa6e4c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions