Fixing the issue – Conda cannot call correct Python version after activating the environment

Conda cannot call correct Python version after activating the environment is an error which occurs because of a namespace clash when importing numpy.

I’m going to provide a detailed and clear explanation of why this error is happening and how to solve it, I am also going to present other ways to get rid of this problem for good.

Exploring the issue : Conda cannot call correct Python version after activating the environment

This is an error which occurs because of a namespace clash when importing numpy.

Please double check the error message in this blog post so you can avoid mixing between different python issues.

                                                                       #
# after running :  source activate mypython34
# and after running :  python --version
Python 2.x.x :: Anaconda 2.x.x (64-bit)
                                                                       #

Bellow is a number of tested solutions that I have tried and that have worked for me.

The Method which solved my issue : import numpy and other libraries without causing a namespace clash and/or exit the default “base” environment

We have already established the fact that the problem we have is caused by a namespace clash

If you import your libraries like this

                                                                       #
from numpy import *
from sympy import *
from warnings import *
                                                                       #

This is going to result in the error we are dealing with.

The solutio is to import the numpy library for example like this

                                                                       #
import numpy as np
                                                                       #

Instead of doing this

                                                                       #
from numpy import *
                                                                       #

You should do this for all the imported libraries

                                                                       #
import warnings as warnings
import numpy as npy
import sympy as spy
                                                                       #

Now, the error should disappear, since you wont be using * , thus the conflict between the libraries is not present since you will be using npy and spy etc.

Another option that you might try if the main method does not work, is to use conda deactivate

                                                                       #
conda deactivate
                                                                       #

Followed by this command

                                                                       #
conda activate foo_env
                                                                       #

Then make sure you exit the default “base” environment because conda will load this environment by default when you initialize the terminal. 

I hope the fixes above fixed your problem. Thank you for reading this blog post to the end.

Summing-up : 

This is the end of this article, I hope we helped you solve the error : Conda cannot call correct Python version after activating the environment or at least show you why it happens and guided you in the right direction. If you want to help, you can donate to our Kofi account.

Thank you for reading my blog post to the end, If you want to learn more about the Python programming language, check out the official Python Documentation : https://docs.python.org/3/