Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

python - 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
    
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am not sure what causes the problem in your case, but code below works for me without any issues (OS?X, the same version of Conda as yours).

Creation of the environment

conda create -n test_env python=3.6.3 anaconda

Some explanation of the documentation of conda create is not clear:

  • -n test_env sets name of the environment to test_env

  • python=3.6.3 anaconda says that you want to use python in version 3.6.3 in this environment (exactly the one you have, and you can use a different one if you need it) and package anaconda. You can put all the things you need there, separated with spaces, e.g., sqlite matplotlib requests and specify their versions the same way as for python.

Activation

conda activate test_env

Deactivation

conda deactivate

Getting rid of it

conda remove -n test_env --all

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...