Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an example of how to create env by prefix but with a name #71

Open
davidrpugh opened this issue Feb 23, 2021 · 1 comment
Open

Comments

@davidrpugh
Copy link
Collaborator

Want to show users how to create environment by prefix (i.e., in a particular location) but with a name so that it can be activated by name. This appears to be possible.

https://stackoverflow.com/questions/49638329/how-to-create-conda-env-with-both-name-and-path-specified

@jeskowagner
Copy link

Hi David,

While possible it is (I think) not best practice, because you can have ambiguous environment names this way.
That is, one could end up accidentally creating two environments with the same name.
Conda would not warn about this, neither at the time of creation or activation.

Here an example:

$ mkdir project1 project2                           # create two empty directories
$ conda create --prefix project1/env                # create named ("env") environment
$ conda config --append envs_dirs $(pwd)/project1   # make it discoverable by conda
$ conda create --prefix project2/env                # create another environment with the same name in a different path
$ conda config --append envs_dirs $(pwd)/project2 
$ conda env list                                    # list conda environments
# conda environments:
#
env        /home/user/project1/env
env        /home/user/project2/env
$ conda activate env
(/home/user/project1/env) $                         # the first environment was activated with no warning!

If you try this out on your own device don't forget to clean up your ~/.condarc file when cleaning up afterwards.

All that said, this behavior has been discussed in conda's repository and was not actively discouraged (conda/conda#7831). Still, I believe it might be confusing to learners.

Different opinions on this welcome.

Best, Jesko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants