Skip to content

Unable to run with Python debug library #1412

Closed
@BadSingleton

Description

@BadSingleton

Environment

  • Pythonnet version: master@ f2dc8f1
  • Python version: 3.6 (probably others)
  • Operating System: Ubuntu 20.04 (probably others)
  • .NET Runtime: netcore 3.1, mono

Details

note: Python 3.6 was installed from the deadsnakes PPA.

Repro:

  • Install Python debug packages
  • Create a and use a virtual environment using the Python debug executable
  • Apply/cherry-pick filmor@ee3503b to run with a static libpython
  • change the dotnet_config to "debug" (line ~43 in setup.py)
  • run python -m pythonnet.find_libpython --export and export the result in the environment, make sure it points to the debug library
  • python setup.py develop then run pytest (with either --runtime mono or --runtime netcore)
  • It will error out with:
Failed to initialize pythonnet: System.TypeInitializationException: The type initializer for 'Delegates' threw an exception. ---> System.MissingMethodException: Failed to load symbol PyModule_Create2: /home/user/dev/36-dbg/bin/python: undefined symbol: PyModule_Create2
  at Python.Runtime.Platform.LinuxLoader.GetFunction (System.IntPtr dllHandle, System.String name) [0x00050] in <12881a58dd5544c59504de515c25928b>:0
  at Python.Runtime.Runtime+Delegates.GetFunctionByName (System.String functionName, System.IntPtr libraryHandle) [0x00000] in <12881a58dd5544c59504de515c25928b>:0
  at Python.Runtime.Runtime+Delegates..cctor () [0x01793] in <12881a58dd5544c59504de515c25928b>:0
   --- End of inner exception stack trace ---
  at Python.Runtime.Runtime.PyGILState_Ensure () [0x00000] in <12881a58dd5544c59504de515c25928b>:0
  at Python.Runtime.Loader.Initialize (System.IntPtr data, System.Int32 size) [0x0003c] in <12881a58dd5544c59504de515c25928b>:0
  at Python.Runtime.Runtime.PyGILState_Ensure () [0x00000] in <12881a58dd5544c59504de515c25928b>:0
  at Python.Runtime.Loader.Initialize (System.IntPtr data, System.Int32 size) [0x0003c] in <12881a58dd5544c59504de515c25928b>:0 INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/user/dev/36-dbg/lib/python3.6/site-packages/_pytest/main.py", line 265, in wrap_session

If I fix that, there's another error in the TypeOffsets ctor (all offsets are null)

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