Why Conda cannot call correct Python version after activating the environment?

后端 未结 3 1902
天命终不由人
天命终不由人 2020-12-18 19:19

I have the following conda environment under Linux:

$ conda info -e
# conda environments:
#
py33                     /u21/coyotito/.anaconda/envs/py33
root           


        
相关标签:
3条回答
  • 2020-12-18 19:47

    Landed here with this same issue, but by moving out of the anaconda executable directory, the correct python was called. I was in a directory that contained the python executable that was installed with Anaconda2.

    Example:

    (py35) C:\Anaconda>python --version
    Python 2.7.11 :: Anaconda 4.0.0 (64-bit)
    
    (py35) C:\Anaconda>cd ..
    
    (py35) C:\>python --version
    Python 3.5.2 :: Anaconda 4.2.0 (64-bit)
    
    (py35) C:\>
    
    0 讨论(0)
  • 2020-12-18 19:56

    I had the exact same problem. Not sure what I did to get into that mess, but I solved it with a simple:

    conda deactivate
    conda activate foo_env
    
    0 讨论(0)
  • 2020-12-18 20:01

    TLDR;

    # deactivate Conda environment
    # (until even base environment is deactivated)
    conda deactivate
    # activate your environment
    conda activate your_env_name_goes_here
    

    try this

    Activate an environment A and then check the location of Python package by using the command below.

    python -c "import sys; print(sys.executable)"

    Activate another environment, let's say environment B and rerun the above python command. If conda isn't using the correct Python version then most likely running the above command will print the same path in both environments.

    My conda installation wasn't using the correct version because I had activated my environment on top of the conda base environment.

    Deactivating the base environment and then activating the environment I wanted, worked.

    0 讨论(0)
提交回复
热议问题