I modified my anaconda environment directories. Any environments installed in the alternative directories show their full path in the prompt modifier. I am expecting only the name of the environment. Why is the full path showing up? Is this only aesthetic or will other things be affected?
Typically when creating an environment using anaconda prompt and the command:
>conda create -n my_env
I activate the environment using:
conda activate my_env
and the prompt changes from (base) to:
(my_env)>
I wish to share environments between users on the same machine. Following https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#specify-env-directories I added a file .condarc to the base conda install path containing:
# envs_dirs: - C:\Users\Public\CondaEnvs
Creating a new environment in the same way when I activate this environment I now see:
(C:\Users\Public\CondaEnvs\my_shared_env)
When the environment is active the environment variable CONDA_PROMPT_MODIFIER has also been set to (C:\Users\Public\CondaEnvs\my_shared_env).
The current output of conda config --show is:
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
- ca-certificates
- certifi
- openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_activate_base: True
auto_update_conda: True
bld_path:
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: flexible
channels:
- defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
conda_build: {}
create_default_packages: []
croot: C:\Users\ClibbonA\conda-bld
custom_channels:
pkgs/main: https://repo.anaconda.com
pkgs/free: https://repo.anaconda.com
pkgs/r: https://repo.anaconda.com
pkgs/msys2: https://repo.anaconda.com
pkgs/pro: https://repo.anaconda.com
custom_multichannels:
defaults:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/free
- https://repo.anaconda.com/pkgs/r
- https://repo.anaconda.com/pkgs/msys2
local:
debug: False
default_channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/free
- https://repo.anaconda.com/pkgs/r
- https://repo.anaconda.com/pkgs/msys2
default_python: 3.7
deps_modifier: not_set
dev: False
disallowed_packages: []
download_only: False
dry_run: False
enable_private_envs: False
env_prompt: ({default_env})
envs_dirs:
- C:\Users\Public\CondaEnvs
- C:\Users\ClibbonA\.conda\envs
- C:\ProgramData\Anaconda3\envs
- C:\Users\ClibbonA\AppData\Local\conda\conda\envs
error_upload_url: https://conda.io/conda-post/unexpected-error
extra_safety_checks: False
force: False
force_32bit: False
force_reinstall: False
force_remove: False
ignore_pinned: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
migrated_custom_channels: {}
non_admin_enabled: True
notify_outdated_conda: True
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pip_interop_enabled: False
pkgs_dirs:
- C:\ProgramData\Anaconda3\pkgs
- C:\Users\ClibbonA\.conda\pkgs
- C:\Users\ClibbonA\AppData\Local\conda\conda\pkgs
proxy_servers: {}
prune: False
quiet: False
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
report_errors: None
rollback_enabled: True
root_prefix: C:\ProgramData\Anaconda3
safety_checks: warn
sat_solver: pycosat
shortcuts: True
show_channel_urls: None
solver_ignore_timestamps: False
ssl_verify: True
subdir: win-64
subdirs:
- win-64
- noarch
target_prefix_override:
track_features: []
update_modifier: update_specs
use_index_cache: False
use_local: False
verbosity: 0
whitelist_channels: []
According to the conda documentation, you need to use the command conda config --set env_prompt "({name}) " (use double quotes on windows). Following these instructions, I found that when I deactivate the environment, the prepended string doesn't read (base) , but (Anaconda3) . That's a bit inconsistent with what people report, but maybe it's a windows thing. Just like the double quotes :p
Elsewhere on Stackoverflow someone has looked into the whole thing a bit and shown a few commands which sort of allow to circumvent this problem, although it's not very convenient to keep having to enter them. Based on the answers in that thread, I pieced together the following solution which did the trick for me:
myenv. Place a .condarc file in its directory (i. e., <current directory>\myenv\.condarc). The content of the file should be env_prompt: "({default_env}) " (plus other entries relevant to your project)..condarc file, create one using the command conda config --set env_prompt "({name}) " with a whitespace after the closing parenthesis if you so desire. If such a file exists already, it should contain the line env_prompt: "({name}) ".Now start your conda console. The environment prompt initially shows (Anaconda3) , but as soon as you activate and deactivate your virtual environment, everything's displayed the way it's supposed to. The command conda env list always displays the asterisk next to the correct environment when myenv is activated.
I encountered the same issue and make some tests. I'm not sure how Anaconda handles this internally, but I found that it might be related to the naming of the virtual environment directory. The last level of the virtual environment directory should be named 'envs', for example:
C:\Users\Public\Conda\envs
Then it works. Otherwise, the full path will be displayed. Setting env_prompt is also a way to solve the problem, but it's not perfect since it changes the root environment directory to 'Anaconda3' as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With