pandas 未在JupyterLab中加载 [英] Pandas not loading in JupyterLab
问题描述
开始在JupyterLab中使用Python 3和Pandas进行数据科学项目数周,而没有遇到任何问题.今天,我无法通过标准import pandas as pd
加载熊猫. (请参见下面的错误消息)
我尝试检查以确保在Anaconda环境中安装了熊猫.在采购Anaconda环境后,我同时运行了pip list
和conda list
,并且都显示了安装在Anaconda环境的软件包列表中的pandas 0.25.0.
想知道这是否与JupyterLab的最新版本1.0.2和Jupyter Notebook的最新版本6.0.0有关吗?
我希望import pandas as pd
可以正常工作,但是我得到了:
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-2-7dd3504c366f> in <module>
----> 1 import pandas as pd
~/anaconda3/lib/python3.7/site-packages/pandas/__init__.py in <module>
40 import pandas.core.config_init
41
---> 42 from pandas.core.api import *
43 from pandas.core.sparse.api import *
44 from pandas.tseries.api import *
~/anaconda3/lib/python3.7/site-packages/pandas/core/api.py in <module>
24 )
25 from pandas.core.arrays import Categorical, array
---> 26 from pandas.core.groupby import Grouper
27 from pandas.io.formats.format import set_eng_float_format
28 from pandas.core.index import (Index, CategoricalIndex, Int64Index,
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/__init__.py in <module>
1 from pandas.core.groupby.groupby import GroupBy # noqa: F401
----> 2 from pandas.core.groupby.generic import ( # noqa: F401
3 SeriesGroupBy, DataFrameGroupBy, PanelGroupBy)
4 from pandas.core.groupby.grouper import Grouper # noqa: F401
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py in <module>
40 import pandas.core.indexes.base as ibase
41 from pandas.core.internals import BlockManager, make_block
---> 42 from pandas.core.panel import Panel
43 from pandas.core.series import Series
44
~/anaconda3/lib/python3.7/site-packages/pandas/core/panel.py in <module>
1584 docs={})
1585
-> 1586 ops.add_special_arithmetic_methods(Panel)
1587 ops.add_flex_arithmetic_methods(Panel)
1588 Panel._add_numeric_operations()
~/anaconda3/lib/python3.7/site-packages/pandas/core/ops/__init__.py in add_special_arithmetic_methods(cls)
810 special methods will be defined and pinned to this class
811 """
--> 812 _, _, arith_method, comp_method, bool_method = _get_method_wrappers(cls)
813 new_methods = _create_methods(
814 cls, arith_method, comp_method, bool_method, special=True
~/anaconda3/lib/python3.7/site-packages/pandas/core/ops/__init__.py in _get_method_wrappers(cls)
717 comp_special = _comp_method_FRAME
718 bool_special = _arith_method_FRAME
--> 719 return arith_flex, comp_flex, arith_special, comp_special, bool_special
720
721
UnboundLocalError: local variable 'arith_flex' referenced before assignment
感谢您的帮助或建议.
最终,我使用 Anaconda列出的默认版本. /p>
Been working on a data science project for a few weeks in JupyterLab using Python 3 and Pandas w/o any issues. Today I can't load pandas via the standard import pandas as pd
. (see error message below)
I've tried checking to make sure pandas is installed in my Anaconda environment. After sourcing my Anaconda environment I've run both pip list
and conda list
and both show pandas 0.25.0 as installed in the packages list for the Anaconda environment.
Wondering if this might be related to a recent update of JupyterLab to version 1.0.2 and update of Jupyter Notebook to version 6.0.0?
I expect import pandas as pd
to work fine but instead I get:
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-2-7dd3504c366f> in <module>
----> 1 import pandas as pd
~/anaconda3/lib/python3.7/site-packages/pandas/__init__.py in <module>
40 import pandas.core.config_init
41
---> 42 from pandas.core.api import *
43 from pandas.core.sparse.api import *
44 from pandas.tseries.api import *
~/anaconda3/lib/python3.7/site-packages/pandas/core/api.py in <module>
24 )
25 from pandas.core.arrays import Categorical, array
---> 26 from pandas.core.groupby import Grouper
27 from pandas.io.formats.format import set_eng_float_format
28 from pandas.core.index import (Index, CategoricalIndex, Int64Index,
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/__init__.py in <module>
1 from pandas.core.groupby.groupby import GroupBy # noqa: F401
----> 2 from pandas.core.groupby.generic import ( # noqa: F401
3 SeriesGroupBy, DataFrameGroupBy, PanelGroupBy)
4 from pandas.core.groupby.grouper import Grouper # noqa: F401
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py in <module>
40 import pandas.core.indexes.base as ibase
41 from pandas.core.internals import BlockManager, make_block
---> 42 from pandas.core.panel import Panel
43 from pandas.core.series import Series
44
~/anaconda3/lib/python3.7/site-packages/pandas/core/panel.py in <module>
1584 docs={})
1585
-> 1586 ops.add_special_arithmetic_methods(Panel)
1587 ops.add_flex_arithmetic_methods(Panel)
1588 Panel._add_numeric_operations()
~/anaconda3/lib/python3.7/site-packages/pandas/core/ops/__init__.py in add_special_arithmetic_methods(cls)
810 special methods will be defined and pinned to this class
811 """
--> 812 _, _, arith_method, comp_method, bool_method = _get_method_wrappers(cls)
813 new_methods = _create_methods(
814 cls, arith_method, comp_method, bool_method, special=True
~/anaconda3/lib/python3.7/site-packages/pandas/core/ops/__init__.py in _get_method_wrappers(cls)
717 comp_special = _comp_method_FRAME
718 bool_special = _arith_method_FRAME
--> 719 return arith_flex, comp_flex, arith_special, comp_special, bool_special
720
721
UnboundLocalError: local variable 'arith_flex' referenced before assignment
Thanks for any help or suggestions.
Ultimately I solved this dependency issue by uninstalling and reinstalling Anaconda using this guide. This was in part aligned with @Trenton_M 's suggestion/info above as the reinstall rolled Pandas back from version 0.25.0 to version 0.24.2 while keeping JupyterLab version 1.0.2 and Jupyter Notebook version 6.0.0.
pandas.__version__
output
'0.24.2'
which is the default version listed for Anaconda.
这篇关于 pandas 未在JupyterLab中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!