RuntimeError: incompatible bytecode version

Hello everybody! First of all, congratulations on such a great tool. Streamlit has allowed people with little to no web development prior knowledge like myself to share out content, so thank you for that!

This is my first post, and actually my first data science project, so please if I’m wrong at any point, do point it out for future occasions.

Well, let’s get on with it… I’ve built an application that runs smoothly locally, but not when deployed with Streamlit Sharing platfrom. At some point in the code, I call a SHAP explainer that I load using joblib. This triggers the following error:


RuntimeError: incompatible bytecode version
Traceback:
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)
File "/app/tfm_kschool/frontend/streamlit_flight_delay_predictor.py", line 552, in <module>
    explainer, shap_values = load_shap_explainer('/app/tfm_kschool/frontend/shap_treeExplainer.bz2', X_test_transformed)
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/caching.py", line 604, in wrapped_func
    return get_or_create_cached_value()
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/caching.py", line 588, in get_or_create_cached_value
    return_value = func(*args, **kwargs)
File "/app/tfm_kschool/frontend/streamlit_flight_delay_predictor.py", line 455, in load_shap_explainer
    explainer = joblib.load(filename)
File "/home/appuser/venv/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 585, in load
    obj = _unpickle(fobj, filename, mmap_mode)
File "/home/appuser/venv/lib/python3.7/site-packages/joblib/numpy_pickle.py", line 504, in _unpickle
    obj = unpickler.load()
File "/usr/local/lib/python3.7/pickle.py", line 1088, in load
    dispatch[key[0]](self)
File "/usr/local/lib/python3.7/pickle.py", line 1436, in load_reduce
    stack[-1] = func(*args)
File "/home/appuser/venv/lib/python3.7/site-packages/numba/core/serialize.py", line 208, in _unpickle__CustomPickled
    ctor, states = loads(serialized)
File "/home/appuser/venv/lib/python3.7/site-packages/numba/core/serialize.py", line 112, in _rebuild_function
    code = _rebuild_code(*code_reduced)
File "/home/appuser/venv/lib/python3.7/site-packages/numba/core/serialize.py", line 132, in _rebuild_code
    raise RuntimeError("incompatible bytecode version")

I’ve looked it up and some people allocated this error to different Python versions (how can I run command lines in Streamlit?), or even different OS (I run it locally on Windows)

Again, I’m basically new to coding, so a detailed answer for newbies would be much appreciated! :grinning_face_with_smiling_eyes:

Thank you for taking the time to read (and hopefully answer) this post.

Best wishes,
Mario

1 Like

Just in case it helps anybody, I solved the issue. It was as simple as changing the Python version (I didn’t know this could be changed)

1 Like