-
Notifications
You must be signed in to change notification settings - Fork 298
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 Kernel dies when using ibm_db.connect #9347
Comments
I'm also having these issues with VScode and running Jupyter notebooks - it happens with several cells, at different points in the notebook, so for me, it's not linked to running a specific function. The error message is exactly the same as above.
|
Thanks, @MeganBeckett. Can you confirm that your code cells will run as separate python scripts in VS Code without triggering a kernel panic? Also in ipython and/or jupyter environment (Jupyterlab etc) outside VS Code? There is some extra process in VS Code Jupyter that does not occur elsewhere. |
@parodayco @MeganBeckett |
@DonJayamanne I pasted that in my initial post, the error message is from the Jupyter output panel |
@parodayco Please could you paste all of the output, i'd like to see the initial logs with information about the interpreter and paths, and the like. Please could you also provide the following info:
import os
print(os.environ)
import sys
print(sys.path) |
This comment was marked as off-topic.
This comment was marked as off-topic.
@DonJayamanne
Cell 1
Cell 2
Cell 3
Output
not calling any environmental variables All above code consolidated and run in a test.py works fine in VS Code. It only fails when run in a test.ipynb |
How are you running test.py in vscode? in a terminal or debugging |
It runs successfully in the terminal but shows this when debugging
|
Thanks for that information, however lets not introduce too many other variables for now. @parodayco Does Jupyter work when you install a previous version like 2021.11.xxx |
@DonJayamanne I tried multiple versions of the Jupyter extension back to 2021.09.11xxx but the kernel process dies with variations of the same error message. For example Warn 2022-03-17 08:45:25: Kernel 17757 as possibly died, StdErr from Kernel Process /Users/philipparodayco/.venv/vscode/lib/python3.9/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5. and {"jsonrpc": "2.0", "method": "kernel_died", "params": {"exit_code": -6, "reason": ""}} |
Hi I'm experiencing the exact same issue, wonder if there's any workaround for now |
@DonJayamanne I saw you renamed this ticket and I'd like to be clear that ibm_db.connect does not call the traitlets module. That is an ipykernel dependency which is required by the VSCode Jupyter extension. The kernel failure does not occur when I run ibm_db.connect elsewhere. |
Please could you provide the following information:
The traitlets module issue is not an error, its just a warning displayed by Jupyter, even Jupyter uses IPyKernel and you'd see this exact same error in jupyter as well (if you enable the logging). I understand the error message indicates that it could be the cause, but thats a best guess from our end looking at the output in stderr stream. |
That's the thing, Don. When I enable the Log Console in Jupyterlab and set the proper levels, it shows no warning message about traitlets and no errors running ibm_db.connect. The kernel does not crash and I am able to execute queries. |
@parodayco
Looking at the information you provided, when you run Jupyter outside vs code i think you are using Please try the following:
|
@DonJayamanne I followed your instructions except I created two virtual environments.
Here are the outputs you requested:
Both environments are running python 3.9.12 The ibm_db connection works in Jupyterlab but dies in VS Code using the current Jupyter extension. Here is the full output.
|
@parodayco Thanks for the information and your patience. I'm still at a loss as to why this is happening. "jupyter.enablePythonKernelLogging": true Also, how are you running Jupyter Lab form the terminal. python3 -m venv test && . test/bin/activate && python -m pip install ipykernel ibm-db && export PYTHONNOUSERSITE=True && python -m jupyter lab Basically setup the env variable |
@DonJayamanne no worries, I'm happy to help solve this. The
p.s. I have no python packages installed in my Library. You were correct about how I ran Jupyterlab. I added the env variable you requested and restarted lab. The ibm-db connection still worked fine and I validated For VS Code, I enabled the logging you requested and attached the full output with the kernel crash. |
Looking at the paths, there seems to be a slight difference in the paths. Please could you let me know which one (Jupyter or VS Code) outputs the value Please could you update to the latest pre-release version of the Jupyter extension & send the logs once again.
Also, please could you print the env variables from Jupyter as well as VS Code so I could compare them (optionally you could compare them your self if you believe there's sensitive information in any of the env variables). |
@DonJayamanne that Library path was empty, an artifact of installing poetry. I uninstalled poetry and removed the entire Library/Python folder. It no longer shows up in I installed the latest pre-release Jupyter extension v2022.4.1000912146 but the kernel still crashes on Here is You'll see |
@parodayco looking at the logs you seem to be using two separate venvs, one named |
@parodayco as suspected its the env variables and based on the docs here https://github.com/ibmdb/python-ibmdb#installation In your case it works for Jupyter lab as this is setup somewhere in one of your shell login scripts. Please create a file named
|
Please let me know how that goes. The feed back here would help so that we can prioritize such issues in the future. |
@DonJayamanne I created an I use VS Code all the time since I run many notebooks that do not depend on a Db2 connection. To be honest, I use jaydebeapi on my laptop but wished to use ibm-db since it's the default connector in our production environment. Now I can edit and run the same notebook code in both places. Thank you so much for you help. My only feedback is that your documentation could do better at explaining how VS Code reads env variables, since it has very specific limitations and requirements. I originally believed that VS Code was reading my
...yet the kernel crashed when I ran VS Code requires me to store that DYLD_LIBRARY_PATH in an Any way, thank you again for all your patience and help. I appreciate it immensely. |
thanks for the feedback and confirming the fix |
Is the issue in the log above related to this? Thank you! |
no idea, please try the solution described above |
I cannot get ibm_db to work in vs code on macOS. My notebook runs fine in jupyter lab, but attempting to connect to a database crashes the kernel in vs code. I think the reason is that environment variable DYLD_LIBRARY_PATH isn't defined in vs code. I have attempted to fix that with a .env file, launch.json, and using python-dotenv. Nothing seems to get that environment variable set properly. The solution above doesn't provide enough details on what should be in the .env file, where it should be located, how to ensure vs code loads it, and how to ensure the DYLD_LIBRARY_PATH is set before attempting to connect to a database. Can someone help? |
Heres the necessary info https://github.com/microsoft/vscode-jupyter/wiki/Kernel-crashes-when-using-ibm-db |
.env loading doesn't work with python 3.10.8 which is what is currently shipping with anaconda. What I found is that |
Actually what I found is that Apple SIP is stripping all DYLD_* environment variables out of the .env file. ibm_db works in a .py file run in VS Code, but the same Python code in a jupyter notebook crashes the kernel because DYLD_LIBRARY_PATH is not defined, no matter what I try to do. This might have something to do with entitlements and needs:
The issue might be that VS Code is not sending DYLD_LIBRARY_PATH to the jupyter notebook subprocess when it starts its kernel. I have tried setting that environment variable from .zprofile, in a .env file loaded by vscode, in the kernel.json file, and using a %env magic in the notebook. In all cases, ibm_db still crashes. It appears DYLD_LIBRARY_PATH is stripped from the environment or not passed to ibm_db running in a jupyter notebook in all cases. |
Issue Type: Bug
My python kernel dies when I run
ibm_db.connect()
oribm_db_dbi.connect()
in VS Code Jupyter notebook cells. Here is the console output:I cannot reproduce the issue outside of the VS Code Jupyter renderer; the same function runs fine as a python script in VS Code and in a local Jupyterlab environment. In all cases, I'm using the same python environment and packages.
MacOS 12.2.1
Python 3.9.10
python3 -m pip install ipykernel jupyterlab pandas ibm-db
Extension version: 2022.2.1924087327
VS Code version: Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:33:49.188Z)
OS version: Darwin x64 21.3.0
Restricted Mode: No
System Info
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Extensions (11)
A/B Experiments
The text was updated successfully, but these errors were encountered: