Skip to content

Not possible to run embed_tests on Ubuntu #489

Closed
@testrunner123

Description

@testrunner123

Environment

  • Pythonnet version: 2.3.0
  • Python version: 3.5 3.4
  • Operating System: Ubuntu 14.04.04 64-bit
  • Mono 4.6

Details

  • Describe what you were trying to get done.
    I am trying to run embed_tests, but they do not run and I get 136 errors like:
  1. SetUp Error : Python.EmbeddingTest.TestPyInt
    System.EntryPointNotFoundException : Py_IsInitialized
    at (wrapper managed-to-native) Python.Runtime.Runtime:Py_IsInitialized ()
    at Python.Runtime.Runtime.Initialize () [0x00001] in <6f2b25faa20d4740b2ac949a9317c3ed>:0
    at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1[T] args, System.Boolean setSysArgv) [0x00016] in <6f2b25faa20d4740b2ac949a9317c3ed>:0
    at Python.Runtime.PythonEngine.Initialize (System.Boolean setSysArgv) [0x00006] in <6f2b25faa20d4740b2ac949a9317c3ed>:0
    at Python.Runtime.PythonEngine.Initialize () [0x00001] in <6f2b25faa20d4740b2ac949a9317c3ed>:0
    at Python.EmbeddingTest.TestPyInt.SetUp () [0x00001] in :0
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0

The main point is here: "Py_IsInitialized" entry point is not found. The bug is that pythonnet does load "__Internal" library instead of libpython3.4m.so. This happens because setup.py detects if /usr/bin/python3 does link to ".so" and if not then load "__Internal". But this is wrong logic, because loading "__Internal" doesn't make any sense. Never. On Ubuntu Python Interpreter do not load libpythonXXX.so (is statically linked), but library libpythonXXX.so exists !

There are generally 2 cases on Linux:

  1. pythonnet is loaded from Python Interpreter (for example /usr/bin/python3 application)
    How to check: try to resolve entry "Py_IsInitialized" in main application. If resolved then skip (2)
  2. pythonnet is loaded from .NET Application
    How to check: if (1) fails then it is the case. Try to load Python library (libpythonXXX.so) in this case.

nunit3-console.exe --noresult Python.EmbeddingTest.dll

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