Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conda version of pandas mismatch

I use the Anaconda suite for python. I do

import pandas as pd

and then

pd.show_versions()

it shows

pandas: 0.17.1

but if I do

!conda list

it shows

pandas 0.18.1

Why are those different ? Why is the imported pandas version less up to date than the one in conda ? Some attributes do not work for me at this stage (like .rolling) which is a great hassle.
I've already tried
conda update pandas
and then restart spyder, but without any luck

Thanks a lot for your help

----EDITS : pd.__file__ returns

Out[16]: 'C:\Anaconda3\lib\site-packages\pandas\__init__.py'

sys.executable returns

'C:\Anaconda3\python.exe'

I've tried sys.path which returns

Out[15]: ['', 'C:\Anaconda3\python35.zip', 'C:\Anaconda3\DLLs',
'C:\Anaconda3\lib', 'C:\Anaconda3',
'c:\anaconda3\lib\site-packages\setuptools-23.0.0-py3.5.egg',
'C:\Anaconda3\lib\site-packages',
'C:\Anaconda3\lib\site-packages\Sphinx-1.4.1-py3.5.egg',
'C:\Anaconda3\lib\site-packages\win32',
'C:\Anaconda3\lib\site-packages\win32\lib',
'C:\Anaconda3\lib\site-packages\Pythonwin',
'C:\Anaconda3\lib\site-packages\IPython\extensions',
'C:\Users\jeanbaptiste.lepetit\.ipython',
'C:\Anaconda3\lib\site-packages\IPython\extensions',
'C:\Anaconda3\lib\site-packages\IPython\extensions']

pd.__version__ returns

'0.17.1'

It's quite confusing

----------EDIT 2 ----------------
Ok I figures packages where at two places

C:\Anaconda3\lib\site-packages\pandas
and
C:\Anaconda3\pkgs\pandas-0.18.1-np110py35_0\Lib\site-packages\pandas

I manually deleted the first one to see what would happen. then try to import the package : import pandas as pd but it couldn't find it. Trying conda install pandas returns

All requested packages already installed. packages in environment at C:\Anaconda3: pandas 0.18.1 np110py35_0

So I guess it is in this folder that all the conda command go, but import doesn't work. I've tried to add `C:\Anaconda3\pkgs' to the PATH, but with no luck.

Any idea ?

like image 889
JB Lepetit Avatar asked Jun 30 '16 18:06

JB Lepetit


2 Answers

Eventually, fiddling with all the above answers and looking at other stackoverflow questions, I figured that 'pip-installed-packages' would not go in the same directory as 'conda-installed-packages'. Typically, pip-instlled go to C:\Anaconda3\Lib\site-packages while conda-installed go to C:\Anaconda3\pkgs.

I removed manually the 'pandas' folder from C:\Anaconda3\Lib\site-packages, but for some reason, Python was unable to find the remaining conda-installed pandas package even after I added 'C:\Anaconda3\pkgs' to the PATH

Eventually I went for an ad-hoc hardcode to the PATH an added 'C:\Anaconda3\pkgs\pandas-0.18.1-np110py35_0\Lib\site-packages' to the PATH and it worked (for this package at least)

What I don't explain to myself is how python manages to find other conda-installed packages (packages for which there is no "specific" path hardcoded as I've done for pandas.

like image 183
JB Lepetit Avatar answered Oct 13 '22 12:10

JB Lepetit


I had exactly the same problem. I discovered that pandas was not only installed in the two folders indicated by JB Lepetit, but also in "C:\Users\user\AppData\Roaming\Python\Python37\site-packages". It was here where the version of pandas was being taken. The problem was solved by simply erasing the pandas folder from here. Hope this helps.

like image 21
agomez137 Avatar answered Oct 13 '22 11:10

agomez137