简体   繁体   中英

Cannot import pandas: ImportError: cannot import name 'ops'

I am not able to import pandas in the conda environment py35 in a virtual machine. I get this error in the notebook, I started getting this error after I conda force installed tpot package.

After I conda force installed tpot , I conda force installed pandas again since I was getting another attribute error:

AttributeError: module 'pandas' has no attribute 'core'

and since then I've been getting this error when I try to import pandas .

<ipython-input-1-7dd3504c366f> in <module>()
----> 1 import pandas as pd

/anaconda/envs/py35/lib/python3.5/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.stats.api import *

/anaconda/envs/py35/lib/python3.5/site-packages/pandas/core/api.py in <module>()
      8 from pandas.core.dtypes.missing import isna, isnull, notna, notnull
      9 from pandas.core.categorical import Categorical
---> 10 from pandas.core.groupby import Grouper
     11 from pandas.io.formats.format import set_eng_float_format
     12 from pandas.core.index import (Index, CategoricalIndex, Int64Index,

/anaconda/envs/py35/lib/python3.5/site-packages/pandas/core/groupby.py in <module>()
     45 from pandas.core.base import (PandasObject, SelectionMixin, GroupByError,
     46                               DataError, SpecificationError)
---> 47 from pandas.core.index import (Index, MultiIndex,
     48                                CategoricalIndex, _ensure_index)
     49 from pandas.core.categorical import Categorical

/anaconda/envs/py35/lib/python3.5/site-packages/pandas/core/index.py in <module>()
      1 # flake8: noqa
----> 2 from pandas.core.indexes.api import *
      3 from pandas.core.indexes.multi import _sparsify

/anaconda/envs/py35/lib/python3.5/site-packages/pandas/core/indexes/api.py in <module>()
----> 1 from pandas.core.indexes.base import (Index,
      2                                       _new_Index,
      3                                       _ensure_index,
      4                                       _ensure_index_from_sequences,
      5                                       _get_na_value,

/anaconda/envs/py35/lib/python3.5/site-packages/pandas/core/indexes/base.py in <module>()
     57 import pandas.core.sorting as sorting
     58 from pandas.io.formats.printing import pprint_thing
---> 59 from pandas.core.ops import _comp_method_OBJECT_ARRAY
     60 from pandas.core import strings, accessor
     61 from pandas.core.config import get_option

/anaconda/envs/py35/lib/python3.5/site-packages/pandas/core/ops/__init__.py in <module>()
     12 import numpy as np
     13 
---> 14 from pandas._libs import Timedelta, Timestamp, lib, ops as libops
     15 from pandas.errors import NullFrequencyError
     16 from pandas.util._decorators import Appender

ImportError: cannot import name 'ops'``` 


I have had issues with installing pandas in my base environment and then later using a different virtual env in my notebook. You might want to try running this command in the cell above your import code in the notebook:

!pip install --upgrade pandas

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM