我无法在 Databricks 中导入 seaborn

问题描述 投票:0回答:0

从今天开始,我无法使用 Azure Databricks 导入 seaborn。只需将 seaborn 作为 sns 导入即可。我该怎么做才能让它发挥作用?

import seaborn as sns

出现以下错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<command-2875305148995571> in <module>
      2 import numpy as np
      3 import matplotlib.pyplot as plt
----> 4 import seaborn as sns

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    165             # Import the desired module. If you’re seeing this while debugging a failed import,
    166             # look at preceding stack frames for relevant error information.
--> 167             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    168 
    169             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/seaborn/__init__.py in <module>
     10 from .miscplot import *  # noqa: F401,F403
     11 from .axisgrid import *  # noqa: F401,F403
---> 12 from .widgets import *  # noqa: F401,F403
     13 from .colors import xkcd_rgb, crayons  # noqa: F401
     14 from . import cm  # noqa: F401

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    165             # Import the desired module. If you’re seeing this while debugging a failed import,
    166             # look at preceding stack frames for relevant error information.
--> 167             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    168 
    169             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/seaborn/widgets.py in <module>
      5 # Lots of different places that widgets could come from...
      6 try:
----> 7     from ipywidgets import interact, FloatSlider, IntSlider
      8 except ImportError:
      9     import warnings

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    165             # Import the desired module. If you’re seeing this while debugging a failed import,
    166             # look at preceding stack frames for relevant error information.
--> 167             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    168 
    169             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/ipywidgets/__init__.py in <module>
     62     register_comm_target()
     63 
---> 64 _handle_ipython()

/databricks/python/lib/python3.8/site-packages/ipywidgets/__init__.py in _handle_ipython()
     60     if ip is None:
     61         return
---> 62     register_comm_target()
     63 
     64 _handle_ipython()

/databricks/python/lib/python3.8/site-packages/ipywidgets/__init__.py in register_comm_target(kernel)
     47 def register_comm_target(kernel=None):
     48     """Register the jupyter.widget comm target"""
---> 49     comm_manager = get_comm_manager()
     50 
     51     comm_manager.register_target('jupyter.widget', Widget.handle_comm_opened)

/databricks/python/lib/python3.8/site-packages/ipywidgets/__init__.py in get_comm_manager()
     30         ip = get_ipython()
     31 
---> 32         if ip is not None and ip.kernel is not None:
     33             return get_ipython().kernel.comm_manager
     34 

AttributeError: 'IPythonShell' object has no attribute 'kernel'

我试过重启内核,也试过用pip安装seaborn,但是显示已经安装好了

python seaborn databricks azure-databricks
© www.soinside.com 2019 - 2024. All rights reserved.