Search code examples
pythoncondazsh

Why can't I access python from a conda environment?


I wanted to use python inside a conda environment. I was expecting that if I ran the command python then python would start up. What actually happened what that python was not found: see below.

From conda base, I can access python

If I create a new environment, I get the following

(base) x@y ~ % conda create --name test
....
(base) x@y ~ % conda activate test
(test) x@y ~ % python
zsh: command not found: python
(test) x@y ~ % conda install python
Channels:
 - defaults
Platform: osx-64
Collecting package metadata (repodata.json): done
Solving environment: done

# All requested packages already installed.
(test) x@y ~ % python
zsh: command not found: python

Any ideas for how to allow the environment to use python? Intel Mac Sonoma 14.5, zsh.


Solution

  • Creating a conda environment does NOT automatically include Python. Conda is general environment manager. You can have Python conda environments, R conda environments, Julia conda environments, etc.

    You must specify that you want Python as well when you create it.

    conda create -n test python
    

    If you want an R environment, you can use:

    conda create -n r-env r-base
    

    For Julia:

    conda create -n julia-env julia
    

    Neither the R, nor the Julia envs have Python. Just like the Python env does not have R or Julia. An empty conda envirnment, is just that: empty.