-
Notifications
You must be signed in to change notification settings - Fork 748
Not possible to run embed_tests on Ubuntu #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On Ubuntu are you using stock system Python 3.5 or you installed from somewhere else (e.g. Anaconda)? If you are using custom Python can you check the output of ldd for libpython? |
@denfromufa Please:
ldd /usr/bin/python3.4:
|
So what happens is pretty simple. There are 2 usecases:
In runtime.cs using "DllImport" all Python/C API functions are hardwired to "__Internal" library that is in "Mono" main application. This works in (1), but not in (2). |
I added code to load /usr/lib/x86_64-linux-gnu/libpython3.4m.so in Runtime.Initialize(). But now I get another error:
|
Solution that I have found so far for Ubuntu users (I have 14.04 64-bit) is to preload libpython by starting tests with bash command:
Using this command execution of "src\embed_tests" succeed without errors. Note that libpython is inside /usr/lib/x86_64-linux-gnu/ that is not a part of standard ldd search path. Further sysconfig or distutils in Python itself report wrong library path ("LIBDIR" is "/usr/lib"). |
Environment
3.53.4Details
I am trying to run embed_tests, but they do not run and I get 136 errors like:
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:
How to check: try to resolve entry "Py_IsInitialized" in main application. If resolved then skip (2)
How to check: if (1) fails then it is the case. Try to load Python library (libpythonXXX.so) in this case.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
The text was updated successfully, but these errors were encountered: