0

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'``` 


gosuto
  • 5,422
  • 6
  • 36
  • 57
Christa
  • 643
  • 2
  • 10
  • 17
  • 1
    Have you tried reinstalling pandas using `sudo pip uninstall pandas` repeatedly until no installation was found and then reinstalling it using `sudo pip install pandas`? – michip96 Jan 28 '20 at 16:36
  • Can you verify your Pandas version using print(pd.__version__)? – csteel Mar 17 '20 at 16:17

1 Answers1

2

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
csteel
  • 428
  • 1
  • 3
  • 14