I'm running Anaconda 3 with Python 3.6 on MacOS 10.12.
I created an environment using python 2.7 and opencv using conda create --name my-env python=2.7 anaconda
(eg here) . I activated the environment using source activate my-env
and installed opencv
. Both creation and activation seem to have worked: the anaconda3/envs/my-env
folder exists and my terminal says (my-env) bob:~ alice
'.
But how do I get Anaconda to use the new environment?
I tried:
Anaconda-Navigator.app
, this just uses the default python path ~/.bash-profile
, but Anaconda still tries the default python path Anaconda-Navigator.app
located in the my-env
folder, fails with the OS error message "cannot be opened" Because I read somewhere that Anaconda 3 might not play nicely with Python 2.7, I tried the same workflow again, but creating an environment using python 3.5.4. Again to no avail.
What am I missing?
there a two possibilities to run a program in an env once the env has been created with conda:
The "Applications on base(root)" can also be changed. If it does not display these options I recommend you to update conda.
My default version of anaconda, the "root(base)" runs with python 2, therefore I added a few lines in my .bash_profile file to easily run python/spyder in either a default env or a specific one. maybe you can use something similar.
NONE='\033[00m'
YELLOW='\033[01;33m'
spy() {
if [[ "${1}" == "" ]]
then
ENV="py36env"
else
ENV=${1}
fi
source activate ${ENV} #enter env
echo -e "${YELLOW}CURRENT ENVIRONMENT: ${ENV} ${NONE}"
spyder #open spyder
echo -e "${YELLOW}EXIT ${ENV} ${NONE}"
source deactivate #exit env when spyder is quitted
}
You can now run spyder in the env "XXX" by entering "spy XXX" in the terminal. Or the default one by typing in "spy".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.