Search code examples
pythonlinuxanacondacondavirtual-environment

Conda incomplete creation of virtual environment after deleting previous environment directory


I am new to Python/Linux. I was trying to set up a new virtual environment using conda. First I tried creating the virtual environment using

conda create -n atomate_env

I realized that this creates the virtual environment in the anaconda directory by default (/home/g2g/anaconda2/atomate_env). However, I wanted create the virtual environment elsewhere. I just deleted the directory of the previous virtual environment, instead of using (I think this where I screwed up)

conda env remove -yn atomate_env

Now I am trying the following

conda create -p /home/g2g/Atomate/atomate_env

to mention the path for creating the virtual environment. It shows me this

Fetching package metadata .........
Solving package specifications: 
Package plan for installation in environment /home/sax041/Atomate/atomate_env:

Proceed ([y]/n)? y

#
# To activate this environment, use:
# > source activate /home/sax041/Atomate/atomate_env
#
# To deactivate this environment, use:
# > source deactivate /home/sax041/Atomate/atomate_env
#

Clearly, it does not list the packages it is going to set up in the new virtual environment. It does create the directory home/sax041/Atomate/atomate_env. This directory is incomplete, with no sub-directory for libraries. It just looks like this

bin  conda-meta

Doing

conda info -e

does not suggest that a new virtual was created

# conda environments:
#
root                  *  /home/g2g/anaconda2

How do I create a complete virtual environment using conda now?


Solution

  • You are already using the correct commands, except you are not specifying to conda that it should install anything into the new environment. You need to specify, for example

    conda create -p /home/g2g/Atomate/atomate_env python=3.6
    

    to install Python. Then, as the instructions state, you have to type

    source activate /home/g2g/Atomate/atomate_env
    

    to activate the environment. However, I don't think that conda info will list environments for which you specify the prefix; although I can't find any official source that says that it won't list them, I can't find anything that says it will list them either.