Running setup works in jupyter lab but not in vscode debug environment, although using same python path

168 views Asked by At

I am running this code in my jupyterlab and in vscode, it works in jupyterlab but does not in vscode. The error appears in the setup function of pycaret. This is my code:

from pycaret.regression(.oop) import * #tried with and without oop
from pycaret.datasets import get_data

data = get_data('insurance')
s = setup(data, target = 'charges', session_id = 123)

Unfortunately I do not get any error message from pycaret. It just says:

Error:

But if I breakpoint before and run pycarets setup code in "Debug Console", I get the following error:

Traceback (most recent call last):
  File "/home/fx/.local/lib/python3.9/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio._simple_templates
  File "/home/fx/.local/lib/python3.9/site-packages/gradio/_simple_templates/__init__.py", line 1, in <module>
    from .simpledropdown import SimpleDropdown
  File "/home/fx/.local/lib/python3.9/site-packages/gradio/_simple_templates/simpledropdown.py", line 6, in <module>
    from gradio.components.base import FormComponent
  File "/home/fx/.local/lib/python3.9/site-packages/gradio/components/__init__.py", line 1, in <module>
    from gradio.components.annotated_image import AnnotatedImage
  File "/home/fx/.local/lib/python3.9/site-packages/gradio/components/annotated_image.py", line 8, in <module>
    from gradio_client.documentation import document, set_documentation_group
  File "/home/fx/.local/lib/python3.9/site-packages/gradio_client/__init__.py", line 1, in <module>
    from gradio_client.client import Client
  File "/home/fx/.local/lib/python3.9/site-packages/gradio_client/client.py", line 22, in <module>
    import httpx
  File "/home/fx/.local/lib/python3.9/site-packages/httpx/__init__.py", line 2, in <module>
    from ._api import delete, get, head, options, patch, post, put, request, stream
  File "/home/fx/.local/lib/python3.9/site-packages/httpx/_api.py", line 4, in <module>
    from ._client import Client
  File "/home/fx/.local/lib/python3.9/site-packages/httpx/_client.py", line 30, in <module>
    from ._transports.default import AsyncHTTPTransport, HTTPTransport
  File "/home/fx/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 30, in <module>
    import httpcore
  File "/home/fx/.local/lib/python3.9/site-packages/httpcore/__init__.py", line 1, in <module>
    from ._api import request, stream
  File "/home/fx/.local/lib/python3.9/site-packages/httpcore/_api.py", line 5, in <module>
    from ._sync.connection_pool import ConnectionPool
  File "/home/fx/.local/lib/python3.9/site-packages/httpcore/_sync/__init__.py", line 1, in <module>
    from .connection import HTTPConnection
  File "/home/fx/.local/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 12, in <module>
    from .._synchronization import Lock
  File "/home/fx/.local/lib/python3.9/site-packages/httpcore/_synchronization.py", line 11, in <module>
    import trio
  File "/home/fx/.local/lib/python3.9/site-packages/trio/__init__.py", line 20, in <module>
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED  # isort: split
  File "/home/fx/.local/lib/python3.9/site-packages/trio/_core/__init__.py", line 21, in <module>
    from ._local import RunVar, RunVarToken
  File "/home/fx/.local/lib/python3.9/site-packages/trio/_core/_local.py", line 9, in <module>
    from . import _run
  File "/home/fx/.local/lib/python3.9/site-packages/trio/_core/_run.py", line 51, in <module>
    from ._multierror import MultiError, concat_tb
  File "/home/fx/.local/lib/python3.9/site-packages/trio/_core/_multierror.py", line 488, in <module>
    assert sys.excepthook is apport_python_hook.apport_excepthook
AssertionError

Also tried to upgrade, but no effect on the behavior:

pip install --upgrade gradio httpx trio

I do use the same environment (python path is the same), pycaret is installed and can be loaded and displays also version, the version is the most recent one (3.2.0), I installed all dependencies.

pip install pycaret[full]

Can anybody help me to solve this?

1

There are 1 answers

1
AldegarRızvan On BEST ANSWER

Thank you furas, I solved it with your help!

I just put a custom excetion hook before my code and it worked.

import sys

def custom_exception_hook(exctype, value, traceback):
    # Your custom exception handling code here
    print(f"Exception Type: {exctype}\nValue: {value}")

sys.excepthook = custom_exception_hook

# Rest of the code

Thank you and have a great day.