3

I want to dynamically store in the project directory, how can I do that? I have searching and found this Can I choose where my conda environment is stored? but this not dynamically store my conda environment to the project directory like virtualenv do

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
iman99
  • 31
  • 1
  • 3
  • 1
    Possible duplicate of [Create a post activate script in Conda](https://stackoverflow.com/questions/34606196/create-a-post-activate-script-in-conda) – identigral Sep 22 '19 at 23:50

1 Answers1

5

Use --prefix, -p for conda create instead of --name, -n.

$ conda create --help
...
Target Environment Specification:
  -n ENVIRONMENT, --name ENVIRONMENT
                        Name of environment.
  -p PATH, --prefix PATH
                        Full path to environment location (i.e. prefix).
...

Usage

conda create -p ./venv python=3.6
conda env list

# activate the local environment with relative or absolute path
conda activate ./venv
conda deactivate

# remove the env
conda env remove -p ./venv
# or just delete the "venv" folder directly

Note: When you set a specific path for your environment with -p, -n is not allowed, which means you cannot give the env a name in this case. You have to operate this kind of envs with their paths.

Simba
  • 23,537
  • 7
  • 64
  • 76