Search code examples
pythonmacosvirtualenvironmentconda

Conda: Creating a virtual environment


I'm trying to create a virtual environment. I've followed steps from both Conda and Medium.

Everything works fine until I need to source the new environment:

conda info -e

# conda environments:
#
base                  *  /Users/fwrenn/anaconda3
test_env                 /Users/fwrenn/anaconda3/envs/test_env

source ~/anaconda3/bin/activate test_env

_CONDA_ROOT=/Users/fwrenn/anaconda3: Command not found. Badly placed ()'s.

I can't figure out the problem. Searching on here has solutions that say adding lines to your bash_profile file, but I don't work in Bash, only C shell (csh). It looks like it's unable to build the directory path in activate.

My particulars:

  • OS X

  • Output of python --version:

    Python 3.6.3 :: Anaconda custom (64-bit)
    
  • Output of conda --version:

    conda 4.4.7
    

Solution

  • I was able to solve my problem. Executing the source activate test_env command wasn't picking up my .bash_profile, and I normally work in tcsh. Simply starting a subprocess in Bash was enough to get activate working. I guess I assumed, incorrectly, that the activate command would start a child process in Bash and use Bash environment variables.

    > conda info -e
    > # conda environments:
    > #
    > base                  *  ~/anaconda3
    > test_env                 ~/anaconda3/envs/test_env
    > bash
    ~$ source ~/anaconda3/bin/activate test_env
    (test_env) ~$
    (test_env) ~$ conda info -e
    # conda environments:
    #
    test_env              *  ~/anaconda3/envs/test_env
    root                     ~/anaconda3