Reputation: 143
I create a virtual environment with conda
$ conda create test_env numpy .....
It gets created successfully.
$ conda env list
# conda environments:
#
base * /home/myname/anaconda3
my_project_env /home/myname/anaconda3/envs/my_project_env
test_env /home/myname/anaconda3/envs/test_env
but I can not activate it
$ source activate my_project_env
returns - activate: No such file or directory
The only place I find activate is within the whole anaconda3 is in /common folder
source anaconda3/envs/my_project_env/lib/python3.6/venv/scripts/common/activate my_project_env
When I run it with this path I get VENV_PROMPT "kind of environment" but when I check libraries with pip list it returns a global list of installed libraries instead of the selected few.
$ source anaconda3/envs/my_project_env/lib/python3.6/venv/scripts/common/activate my_project_env
__VENV_PROMPT__myname@box:~$ pip3 list
Upvotes: 7
Views: 30415
Reputation: 51
As others have mentioned, it may be a PATH issue. However, if you're still able to run other conda
commands then you may need to either conda update conda
or delete conda and reinstall. In my case, I was running miniconda which I believe simply did not contain the activate
binary.
Running conda activate
instead of source activate
solved my issues.
Upvotes: 0
Reputation: 6123
Check your conda version
conda -V
Create virtual environment for your project
conda create -n yourenvname python=x.x anaconda
To activate your virtual environment
source activate yourenvname
Upvotes: 1
Reputation: 46
I met with the same problem. It is because I have changed the system's $PATH variable from anaconda's main bin directory to the environment's bin directory. Actually, the activate's path is under /home/users/anaconda3/bin/. So I just use the following command to make a link between the two bin directories:
ln -s /home/userName/anaconda3/bin/activate /home/userName/anaconda3/envs/envName/bin/activate
ln -s /home/userName/anaconda3/bin/deactivate /home/userName/anaconda3/envs/envName/bin/deactivate
Upvotes: 3
Reputation: 770
Try to use this command activate your conda environment:
source activate /home/myname/anaconda3/envs/my_project_env
Recommended command to create environment with python version 2.7 :
conda create -n my_project_env python=2.7
Upvotes: 4