how to revert back to default behavior of env_prompt parameter in .condarc?

Related searches

If you create a python environment in conda with --prefix flag and activate it, post-activation the environment is shown by its entire path. This could be a very long path and hence the conda-documentation suggests a fix as follows.

conda config --set env_prompt '({name})'

The problem is when you deactivate this environment, then you don't go back to the default behavior. Even if you activate the base environment, it would show you the entire path of the base environment instead of just (base).

For instance, I installed the conda environment under path Users/username/Documents/GitHub/test_flask/.env on the C-drive (Windows 10). BEFORE applying the command (conda config --set env_prompt '({name})'), post activation it looks like this:

(C:\Users\username\Documents\GitHub\test_flask\.env) C:\Users\username\Documents\GitHub\test_flask>

And AFTER applying the command (conda config --set env_prompt '({name})'), if I activate the environment, it looks like this:

(.env) C:\Users\username\Documents\GitHub\test_flask>

Great! But now if I deactivate this environment and/or activate my base environment, I get this:

'(Anaconda3)'C:\Users\username\Documents\GitHub\test_flask>

However, I would like to get back:

'(base)'C:\Users\username\Documents\GitHub\test_flask>

So, how to fix this?

As far as I understand, commands beggining with conda env config vars should address such issues, but for some reason me changing env_prompt variable with such a command took no effect.

But I figured out an alternative way: all you need is just to put a brand-new .condarc file in the root of your environment. In your case, C:\Users\username\Documents\GitHub\test_flask\.env\.condarc. And such contents should be enough:

env_prompt: '({name}) '

Note that you may need to activate your environment twice (the first one to load local .condarc and the second one to apply it).

Alternative way to do so is to use --env option with conda config while desired environment being active:

conda activate .\.env
conda config --set env_prompt '({name})' --env

It seems to be more robust and convenient way but it was inappropriate for me because I was working in context of makefile.

If you use command conda info you are able to see which configuration files are in effect.

Using the .condarc conda configuration file — conda 4.8.4.post21+ , The .condarc file can change many parameters, including: What default packages or features to include in new environments. If you have issues with long paths, you may need to disable this behavior. to change the build output root directory with the root-dir setting described above, but fall back to this as necessary:. how to revert back to default behavior of env_prompt parameter in .condarc? If you create a python environment in conda with --prefix flag and activate it, post-activation the environment is shown by its entire path.

Solution

It turns out that you need to do the following to get back the default behavior. Here we set the default behavior of env_prompt variable in .condarc file, again before deactivating the environment that was installed at a non-default location.

Assuming you create your python-environment directory (.env) under your project directory as follows:

conda env create --prefix ./.env -f envirnment.yml

Follow these steps for activating and deactivating the environment.

# for activating env
conda config --set env_prompt '({name})'
conda activate ./.env


# for deactivating env
conda config --set env_prompt '({default_env})'
conda deactivate
conda activate base

Description of the env_prompt variable

Source: conda-config: .condarc file

### .condarc file (env_prompt section)

# # env_prompt (str)
# #   Template for prompt modification based on the active environment.
# #   Currently supported template variables are '{prefix}', '{name}', and
# #   '{default_env}'. '{prefix}' is the absolute path to the active
# #   environment. '{name}' is the basename of the active environment
# #   prefix. '{default_env}' holds the value of '{name}' if the active
# #   environment is a conda named environment ('-n' flag), or otherwise
# #   holds the value of '{prefix}'. Templating uses python's str.format()
# #   method.
# # 
# env_prompt: '({default_env}) '

Release notes — conda 4.8.4.post21+ad15eb51 documentation, Standardize "conda env list" behavior between platforms (#9166) These can be set in condarc or using environment variables. Resolve #7724 move windows package cache and envs dirs back to .conda directory (#7725). Disallow Backport 'allow_conda_downgrade' configuration parameter, default is False (#7998). Name the new file .condarc and save it to your user home directory or root directory. To edit the .condarc file, open it from your home or root directory and make edits in the same way you would with any other text file. If the .condarc file is in the root environment, it will override any in the home directory.

There is a more babarian method ! The "issue" comes from the .condrac file.

  1. Deleting the file works (mine was located at C:\Users\username but the .condarc doc gives you other places if you don't find it). The next time you --set smth in the .condarc file, conda will re-summon it.

  2. If you already used the conda config command then you .condarc file probably countains other lines than just env_prompt: "...". Then find the file, open it (Notepad++ works well) and delete the affected line.

My OS : Win10-64 last version

conda install — conda 4.8.4.post45+6d1fea11 documentation, Then, the defaults or channels from .condarc are searched (unless --override- channels is Conda will try whatever you specify, but will ultimately fall back to� So, I think that’s pretty awesome – and really handy if you screw things up and want to go back to a previously working environment. I’ve got a few other hints for you though… Firstly, if you ‘revert’ to a previous revision then you will find that an ‘inverse’ revision is created, simply doing the opposite of what the previous

[PDF] conda Documentation, Change your current environment back to the default (base):. • Windows: The . condarc file can change many parameters, including:. Temporarily set your ssl_verify variable to false, upgrade the requests package, and then set ssl_verify back to true using the following commands: conda config --set ssl_verify false conda update requests conda config --set ssl_verify true You can also set ssl_verify to a string path to a certificate, which can be used to verify SSL connections.

Go deeper on how to manage packages. Learn more Change your current environment back to the default (base): conda activate To remove this long prefix in your shell prompt, modify the env_prompt setting in your .condarc file: parameter is in BETA, and its behavior may change in a future release. This # # parameter is in BETA, and its behavior may change in a future release. # # # pinned_packages: [] # # pip_interop_enabled (bool) # # Allow the conda solver to interact with non-conda-installed python # # packages. # # # pip_interop_enabled: false # # track_features (sequence: primitive) # # env var string delimiter: ',' # # A list of

Conda keeps a history of all the changes made to your environment, so you can easily "roll back" to a previous version. To list the history of each change to the current environment: conda list--revisions. To restore environment to a previous revision: conda install--revision=REVNUM or conda install--rev REVNUM.