Skip to content
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

nogil runtime error #83

Open
houshijie-2020 opened this issue Sep 1, 2022 · 3 comments
Open

nogil runtime error #83

houshijie-2020 opened this issue Sep 1, 2022 · 3 comments

Comments

@houshijie-2020
Copy link

printf Py_GetPythonHome : /usr/local/nogil-py/

printf Py_GetPythonPath : /usr/local/nogil-py/lib/python39.zip:/usr/local/nogil-py/lib:/usr/local/nogil-py/lib/python3.9/site-packages:/usr/local/nogil-py/lib/python3.9:/usr/local/nogil-py/lib/python3.9/lib-dynload:/usr/local/nogil-py/lib/python39.zip:/usr/local/nogil-py/lib/python3.9:/usr/local/nogil-py/lib/python3.9/lib-dynload

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/nogil-py/lib/python3.9/site-packages/MNN/init.py", line 4, in
from _mnncengine import *
ImportError: /usr/local/nogil-py/lib/python3.9/site-packages/_mnncengine.nogil-39b-x86_64-linux-gnu.so: undefined symbol: _Py_TrueStruct

@houshijie-2020
Copy link
Author

houshijie-2020 commented Sep 1, 2022

#include
#include <stdio.h>
#include

#include "Python.h"

using namespace std;

void Python_run_str(const string& str)
{
PyRun_SimpleString(str.c_str());

}

void Python_run_file(const string& file_name)
{
FILE* file;
file = fopen(file_name.c_str(), "r");
PyRun_SimpleFile(file, file_name.c_str());
fclose(file);
}

int main()
{
printf("printf Py_GetPythonHome : %ls\n\n\n\n", Py_GetPythonHome());

Py_Initialize();
printf("printf content start: %ls\n\n\n\n", Py_GetPath());
Python_run_str("import  MNN\nprint('import  MNN sucessfully')\n");

if (Py_FinalizeEx() < 0) {
    cout << "Py_FinalizeEx err" << endl;
    exit(120);
}

int a = 0;
cout << "input a integer" << endl;
cin >> a;
return 0;

}

@colesbury
Copy link
Owner

It's not clear to me what's you're trying to do. It looks like you have a custom C API extension and also are trying to embed the interpreter? It looks likely that you have some build misconfiguration.

Can you put together a complete reproduction, including the code and commands to build it?

@houshijie-2020
Copy link
Author

houshijie-2020 commented Sep 2, 2022

i am trying to embed the interpreter (MNN is a a custom C API extension)
the comiple command:
gcc test_mnn.cpp -lstdc++ -I/usr/local/nogil-py/include/python3.9/ -lm -L/usr/local/nogil-py/lib/ -lpython3.9 -lpthread -lutil -ldl -o test_mnn

gcc version:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.0 (GCC)

export:
export PYTHONPATH=/usr/local/nogil-py/lib/python39.zip:/usr/local/nogil-py/lib:/usr/local/nogil-py/lib/python3.9/site-packages:/usr/local/nogil-py/lib/python3.9:/usr/local/nogil-py/lib/python3.9/lib-dynload

export PYTHONHOME=/usr/local/nogil-py/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants