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

python SDK import openmldb failed in ipython/notebook MacOS #1200

Closed
HuilinWu2 opened this issue Feb 11, 2022 · 7 comments
Closed

python SDK import openmldb failed in ipython/notebook MacOS #1200

HuilinWu2 opened this issue Feb 11, 2022 · 7 comments
Assignees
Labels
bug Something isn't working python Pull requests that update Python code sdk openmldb java/python sdk

Comments

@HuilinWu2
Copy link
Collaborator

ImportError: dlopen(/Users/huilin/PycharmProjects/0211/venv/lib/python3.8/site-packages/openmldb/dbapi/../native/_sql_router_sdk.so, 2): initializer function 0x7fff67bc5357 not in mapped image for /Users/huilin/PycharmProjects/0211/venv/lib/python3.8/site-packages/openmldb/dbapi/../native/_sql_router_sdk.so

However, it works in Linux with python/ipython, Mac with python.

@HuilinWu2 HuilinWu2 added the bug Something isn't working label Feb 11, 2022
@vagetablechicken
Copy link
Collaborator

I've got this error too. Just in python3.9, it seems like this error does not only in ipython or notebook.

@vagetablechicken
Copy link
Collaborator

One more error when running python on mac:

[libprotobuf FATAL /Users/runner/work/crossbow/crossbow/vcpkg/buildtrees/protobuf/src/23fa7edd52-3ba2225d30.clean/src/google/protobuf/stubs/common.cc:87] This program was compiled against version 3.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.15.8).  Contact the program author for an update.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "/Users/ark/Code/OpenMLDB/src/proto/common.pb.cc".)
libc++abi.dylib: terminating with uncaught exception of type google::protobuf::FatalException: This program was compiled against version 3.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.15.8).  Contact the program author for an update.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "/Users/ark/Code/OpenMLDB/src/proto/common.pb.cc".)

@vagetablechicken
Copy link
Collaborator

vagetablechicken commented May 11, 2022

still get initializer function error on openmldb python sdk 0.5.0, my machine is macos-10.15,

ld: warning: object file (/Users/ark/Code/OpenMLDB/.deps/usr/lib/libzetasql.a(unparser.o)) was built for newer macOS version (12.1) than being linked (10.15)
zetasql is built on 12.1.
I'll try to use 10.15 zetasql or build bundle in my own machine.

Not the root cause, forget it.

@vagetablechicken
Copy link
Collaborator

10.15 zetasql still failed.
So I test released 050 python sdk again.
Important
Only sqlalchemy will fail.

import sqlalchemy as db

It works when importing sdk or dbapi.(Just one import, not both of them.)
If we import openmldb, then import sqlalchemy, it works.

@vagetablechicken
Copy link
Collaborator

I check it in python virtual env only has python3.9, I named mypython3.9. In the pure env, I use the pytest in it, not in system path. /usr/local/anaconda3/envs/mypython3.9/bin/pytest.

The the test will all pass. No dlopen error.

But even in the mypython3.9, when I try python train_and_serve.py in talking data demo. It'll failed, even I import openmldb first.

import openmldb
import sqlalchemy

But when I comment pandas and xgboost imports, only openmldb, it works. So I make the import order:

  1. openmldb
  2. sqlalchemy
  3. pandas and xgboost

It's ok now.

@aceforeverd aceforeverd added python Pull requests that update Python code sdk openmldb java/python sdk labels Jun 7, 2022
@vagetablechicken
Copy link
Collaborator

vagetablechicken commented Jun 8, 2022

 import gc
 import os
 import time
 import glob
 # fmt:off
 import openmldb
 import sqlalchemy as db
 import pandas as pd
 import xgboost as xgb
 import requests
 # fmt:on

pandas, xgboost, requests should be after openmldb.
Otherwise, it will cause ImportError: dlopen(/usr/local/anaconda3/envs/mypython3.9-1/lib/python3.9/site-packages/openmldb/native/_sql_router_sdk.so, 2): initializer function 0x10d6c39b0 not in mapped image for /usr/local/anaconda3/envs/mypython3.9-1/lib/python3.9/site-packages/openmldb/native/_sql_router_sdk.so

note
If we met this error, we can make the right import sort order to avoid it.
But the root cause is that _sql_router_sdk.so has missing function when load it. The error is thrown by containsAddress failed, called by the two func(which one?):

	doImageInit(context);
	doModInitFunctions(context);

ref https://opensource.apple.com/source/dyld/dyld-353.2.1/src/ImageLoaderMachO.cpp

bool ImageLoader::containsAddress(const void* addr) const
{
	for(unsigned int i=0, e=segmentCount(); i < e; ++i) {
		const uint8_t* start = (const uint8_t*)segActualLoadAddress(i);
		const uint8_t* end = (const uint8_t*)segActualEndAddress(i);
		if ( (start <= addr) && (addr < end) && !segUnaccessible(i) )
			return true;
	}
	return false;
}

If we don't import openmldb first or don't import it, _sql_router_sdk.so will get the wrong segment(load some libs in higher version) or no right segment?

@vagetablechicken
Copy link
Collaborator

vagetablechicken commented Apr 6, 2023

another error
python sdk 0.7.2 released by macos-12, run on macos 12.1 python 3.8.2

ImportError: dlopen(...sdk.so, 0x0002): symbol not found in flat namespace '_PyCMethod_New'

I think 3.8.2 is old, 3.8.10 or 3.9?
3.9 works.
Memo it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests that update Python code sdk openmldb java/python sdk
Projects
None yet
Development

No branches or pull requests

5 participants