OpenBB icon indicating copy to clipboard operation
OpenBB copied to clipboard

[Bug] Jupiter Notebook not loading the kernel on browser when trying to use the OpenBB SDK

Open rserranon opened this issue 2 years ago • 7 comments

Whenever I create a new .ipynb file to use OpenBB SDK, the kernel doesn't seem to load, if I do:

from openbb_terminal.sdk import openbb

I get this error on the browser:

ModuleNotFoundError                       Traceback (most recent call last)
/var/folders/dm/y81m2jm566lcd943x_y5mjsw0000gn/T/ipykernel_404/3073663393.py in <module>
----> 1 from openbb_terminal.sdk import openbb

~/OpenBBTerminal/openbb_terminal/sdk.py in <module>
      1 # pylint: disable=unused-import
----> 2 from openbb_terminal.config_terminal import theme  # noqa: F401
      3 from openbb_terminal.helper_classes import TerminalStyle
      4 from openbb_terminal import helper_funcs as helper  # noqa: F401
      5 from openbb_terminal.reports import widget_helpers as widgets  # noqa: F401

~/OpenBBTerminal/openbb_terminal/config_terminal.py in <module>
      4 
      5 # IMPORTATION THIRDPARTY
----> 6 import dotenv
      7 
      8 # IMPORTATION INTERNAL

ModuleNotFoundError: No module named 'dotenv'

Desktop:

  • OS: Mac M1 BigSur
  • Python 3.9.15

rserranon avatar Feb 02 '23 19:02 rserranon

Jupyter Lab/Notebook, when run in the browser app, is the only critical failure point in the native M1 environments. The kernel just does not engage. Running via the Jupyter integration with VS Code, however, runs perfectly. I know this is M1-native specific because creating the same environment build as x86 architecture works as expected.

[I 2023-02-02 11:35:25.208 LabApp] Build is up to date
[I 2023-02-02 11:35:25.901 ServerApp] Kernel started: c36559d1-bfae-4641-9caa-4803a5f3de18
2023-02-02 11:35:49.083 python3.10[37688:923848] *** Assertion failure in +[NSEvent otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:], NSEvent.m:647
2023-02-02 11:35:49.123 python3.10[37688:923848] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: _NSEventMask64FromType(type) & WeirdMask'
*** First throw call stack:
(
        0   CoreFoundation                      0x00000001a300f3f8 __exceptionPreprocess + 176
        1   libobjc.A.dylib                     0x00000001a2b5aea8 objc_exception_throw + 60
        2   Foundation                          0x00000001a3f50a60 -[NSCalendarDate initWithCoder:] + 0
        3   AppKit                              0x00000001a63b8250 +[NSEvent otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:] + 264
        4   libffi.8.dylib                      0x0000000100f8004c ffi_call_SYSV + 76
        5   libffi.8.dylib                      0x0000000100f7d74c ffi_call_int + 1208
        6   _ctypes.cpython-310-darwin.so       0x0000000100f60a30 _ctypes_callproc + 1324
        7   _ctypes.cpython-310-darwin.so       0x0000000100f5abf8 PyCFuncPtr_call + 1160
        8   python3.10                          0x000000010031a294 _PyObject_MakeTpCall + 612
        9   python3.10                          0x00000001004090f0 call_function + 676
        10  python3.10                          0x0000000100404e58 _PyEval_EvalFrameDefault + 26500
        11  python3.10                          0x00000001003fddc8 _PyEval_Vector + 2056
        12  python3.10                          0x0000000100409058 call_function + 524
        13  python3.10                          0x0000000100404e58 _PyEval_EvalFrameDefault + 26500
        14  python3.10                          0x00000001003fddc8 _PyEval_Vector + 2056
        15  _ctypes.cpython-310-darwin.so       0x0000000100f5ee0c closure_fcn + 644
        16  libffi.8.dylib                      0x0000000100f7db34 ffi_closure_SYSV_inner + 808
        17  libffi.8.dylib                      0x0000000100f801d4 ffi_closure_SYSV + 52
        18  CoreFoundation                      0x00000001a2fae55c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
        19  CoreFoundation                      0x00000001a2fae204 __CFRunLoopDoTimer + 940
        20  CoreFoundation                      0x00000001a2fadd5c __CFRunLoopDoTimers + 356
        21  CoreFoundation                      0x00000001a2f93744 __CFRunLoopRun + 1896
        22  CoreFoundation                      0x00000001a2f92888 CFRunLoopRunSpecific + 612
        23  HIToolbox                           0x00000001ac667fa0 RunCurrentEventLoopInMode + 292
        24  HIToolbox                           0x00000001ac667c30 ReceiveNextEventCommon + 236
        25  HIToolbox                           0x00000001ac667b2c _BlockUntilNextEventMatchingListInModeWithFilter + 72
        26  AppKit                              0x00000001a6214424 _DPSNextEvent + 632
        27  AppKit                              0x00000001a62135b4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
        28  AppKit                              0x00000001a62079e4 -[NSApplication run] + 464
        29  libffi.8.dylib                      0x0000000100f8004c ffi_call_SYSV + 76
        30  libffi.8.dylib                      0x0000000100f7d74c ffi_call_int + 1208
        31  _ctypes.cpython-310-darwin.so       0x0000000100f60a30 _ctypes_callproc + 1324
        32  _ctypes.cpython-310-darwin.so       0x0000000100f5abf8 PyCFuncPtr_call + 1160
        33  python3.10                          0x000000010031a294 _PyObject_MakeTpCall + 612
        34  python3.10                          0x00000001004090f0 call_function + 676
        35  python3.10                          0x0000000100404e58 _PyEval_EvalFrameDefault + 26500
        36  python3.10                          0x00000001003fddc8 _PyEval_Vector + 2056
        37  python3.10                          0x0000000100409058 call_function + 524
        38  python3.10                          0x0000000100404e58 _PyEval_EvalFrameDefault + 26500
        39  python3.10                          0x00000001003fddc8 _PyEval_Vector + 2056
        40  python3.10                          0x0000000100409058 call_function + 524
        41  python3.10                          0x0000000100404e58 _PyEva[I 2023-02-02 11:35:49.882 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-02-02 11:35:49.882 ServerApp] kernel c36559d1-bfae-4641-9caa-4803a5f3de18 restarted
[I 2023-02-02 11:35:49.893 ServerApp] Starting buffering for c36559d1-bfae-4641-9caa-4803a5f3de18:dbb93165-5a75-4dfe-b3c4-28acf55c2b7f
[I 2023-02-02 11:35:49.913 ServerApp] Restoring connection for c36559d1-bfae-4641-9caa-4803a5f3de18:dbb93165-5a75-4dfe-b3c4-28acf55c2b7f
[I 2023-02-02 11:36:20.129 ServerApp] Kernel shutdown: c36559d1-bfae-4641-9caa-4803a5f3de18

deeleeramone avatar Feb 02 '23 20:02 deeleeramone

@rserranon did you pip install openbb or git cloned?

See the image below for either option (I'm assuming that if you git cloned you have created your conda environment with name obb, otherwise replace the conda activate obb with your env name).

pip version (left): I'm just opening a new jupyter notebook file git clone (right): steps in the image

Screenshot 2023-02-08 at 13 31 24

montezdesousa avatar Feb 08 '23 13:02 montezdesousa

the error you are seeing most likely relates to the fact that your default jupyter kernel is not created in an environment that has openbb installed. openbb sdk ships with a jupyter lab so if you launch jupyter lab from the environment that you have installed it to - the default kernel (the most leftward tile icon with a python logo) is going to be the correct kernel.

image ![image](https://user-images.githubusercontent.com/11668535/217659342-8c63295c-d8d5-4b9b-a324-e4e2251051ff.png)

piiq avatar Feb 08 '23 21:02 piiq

the error you are seeing most likely relates to the fact that your default jupyter kernel is not created in an environment that has openbb installed. openbb sdk ships with a jupyter lab so if you launch jupyter lab from the environment that you have installed it to - the default kernel (the most leftward tile icon with a python logo) is going to be the correct kernel.

image ![image](https://user-images.githubusercontent.com/11668535/217659342-8c63295c-d8d5-4b9b-a324-e4e2251051ff.png)

Native M1 versions are not working, the kernel gets rejected, and this is specific to M1 environments. X86 version works as expected.

[I 2023-02-08 15:10:53.920 LabApp] JupyterLab extension loaded from /Users/danglewood/GitHub/Conda_M1/miniconda3/envs/obb-m1/lib/python3.10/site-packages/jupyterlab
[I 2023-02-08 15:10:53.920 LabApp] JupyterLab application directory is /Users/danglewood/GitHub/Conda_M1/miniconda3/envs/obb-m1/share/jupyter/lab

Screenshot 2023-02-08 at 3 12 32 PM

deeleeramone avatar Feb 08 '23 23:02 deeleeramone

the error you are seeing most likely relates to the fact that your default jupyter kernel is not created in an environment that has openbb installed. openbb sdk ships with a jupyter lab so if you launch jupyter lab from the environment that you have installed it to - the default kernel (the most leftward tile icon with a python logo) is going to be the correct kernel.

image ![image](https://user-images.githubusercontent.com/11668535/217659342-8c63295c-d8d5-4b9b-a324-e4e2251051ff.png)

Native M1 versions are not working, the kernel gets rejected, and this is specific to M1 environments. X86 version works as expected.

[I 2023-02-08 15:10:53.920 LabApp] JupyterLab extension loaded from /Users/danglewood/GitHub/Conda_M1/miniconda3/envs/obb-m1/lib/python3.10/site-packages/jupyterlab
[I 2023-02-08 15:10:53.920 LabApp] JupyterLab application directory is /Users/danglewood/GitHub/Conda_M1/miniconda3/envs/obb-m1/share/jupyter/lab

Screenshot 2023-02-08 at 3 12 32 PM

I'm running M1 native and worked fine

montezdesousa avatar Feb 08 '23 23:02 montezdesousa

This was also a reported bug on the MPL GitHub, and the issue seems the same: https://github.com/matplotlib/matplotlib/issues/22545

https://stackoverflow.com/questions/70466222/m1-mac-python-assertion-failure-and-crashes-when-using-osx-as-backend-in-matplo

deeleeramone avatar Feb 08 '23 23:02 deeleeramone

Native M1 versions are not working, the kernel gets rejected, and this is specific to M1 environments. X86 version works as expected.

The screenshot is from an M1 version.

I would like to take the discussion here back to the point that @rserranon made.

We see the terminal being unable to find the dotenv frequently when the terminal is launched from a different python environment than it was installed into. Please check

  1. Which env you are launching the jupyter lab from
  2. Which kernel are you selecting to use the sdk

Let me know if you solved the issue or if the problem persists. We'll try to help

piiq avatar Feb 10 '23 10:02 piiq