Different Numpy Version In Anaconda And Numpy.__version__ In Ipython Shell
Solution 1:
It seems that you have besides your python 3
environment in anaconda
, another python
with IPython
and numpy
installed.
It looks like that PyCharm and Anaconda see (correctly) the same numpy
versions, while IPython
which, I assume you didn't start from within your anaconda environment, sees another python
installation with the older numpy
. In fact, your output shows, that there is another python3.6
in C:\Users\...
which doesn't belong to anaconda
.
To make numpy 1.15
available in IPython
you can either start IPython
from within your anaconda environment by typing in the terminal (easier solution)
C:\>activate <your_anaconda_environment_name>
(<your_anaconda_environment_name>) C:\>ipython
or you make your local IPython
load the modules from the anaconda
environment by having a look at this answer. This will be not a recommended option in this case, given the resulting cross linkings of two python installations.
Solution 2:
The issue is that PyCharm reads older python version from location App-data\roaming...
What I did is that in start-up script, I added the following code.
print("Correcting sys paths now...")
paths = [
'C:\\Anaconda3\\python36.zip',
'C:\\Anaconda3\\DLLs',
'C:\\Anaconda3\\lib',
'C:\\Anaconda3',
'C:\\Anaconda3\\lib\\site-packages',
'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',
]
import sys
forpathin reversed(paths):
sys.path.insert(0,path)
print("Completed correcting sys paths now...")
del path
del paths
Above code will force Python to read latest files from Anaconda. However, if you are using virtual environment, you would need to point to that environment.
If you want to know where is Python installed, you can run:
import os
import sys
os.path.dirname(sys.executable)
Above answer is inspired from conda python isn't using the numpy version I try install if I also specify that it should use python 2. It doesn't provide the solution. I have posted a solution above.
Post a Comment for "Different Numpy Version In Anaconda And Numpy.__version__ In Ipython Shell"