开始在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
感谢您的帮助或建议。
答案 0 :(得分:0)
最终,我使用this guide卸载并重新安装了Anaconda,从而解决了此依赖性问题。这部分与@Trenton_M的上述建议/信息一致,因为重新安装将Pandas从0.25.0版本回滚到0.24.2版本,同时保留了JupyterLab 1.0.2版本和Jupyter Notebook 6.0.0版本。
'0.24.2'
输出
int *p = new int[1e7];