7

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
4
  • sounds like your PATH variable is munged up.
    – Paul H
    Feb 5, 2018 at 23:04
  • 1
    @PaulH wouldn't it worked when I specified it in a command? Where should I expect to find activate file? is it normal for it to be in scripts/commons instead of anaconda3/bin/ any ideas how to fix this issue?
    – Tummomoxie
    Feb 6, 2018 at 8:29
  • What version of conda do you have? The new way to activate environments is conda activate env_name
    – darthbith
    Feb 6, 2018 at 14:44
  • IIRC, the activate script should be in a central locations. not in the environment.
    – Paul H
    Feb 6, 2018 at 14:48

4 Answers 4

4

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
3

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
2
  • I followed the instruction. But, I got this message( bash: In: command not found) and nothing happened. :(((
    – Lim
    Apr 24, 2019 at 10:20
  • Sorry, it is actually ln means making links.
    – c0ldstudy
    Apr 26, 2019 at 6:50
1

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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.