为什么conda提示中包含该路径,以及如何将其缩短

时间:2019-01-11 17:20:06

标签: anaconda conda miniconda

我不久前(在Linux上)将miniconda3安装到了我的系统上。一件很烦人的事情是,当我激活我创建的环境(不包括基本环境)时,提示将显示我的miniconda安装的完整路径,而不仅仅是环境名称。

如何获取仅显示环境名称而不是完整路径和名称的信息。

作为参考,这是我的环境列表

# conda environments:
#
base                  *  /scratch/XXXXXX/miniconda3
eof37                    /scratch/XXXXXX/miniconda3/eof37

这是我使用base的提示

(base) [XXXXXX@server ~]$

这是我使用另一个创建的环境的提示

(/scratch/XXXXXX/miniconda3/eof37) [XXXXXX@server ~]$

并且我希望此提示是

(eof37) [XXXXXX@server ~]$

代替

编辑:更多信息-我的.bashrc中的conda行

# added by Miniconda3 4.5.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$(CONDA_REPORT_ERRORS=false '/scratch/XXXXXX/miniconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
        \eval "$__conda_setup"
else
    if [ -f "/scratch/XXXXXX/miniconda3/etc/profile.d/conda.sh" ]; then
            . "/scratch/XXXXXX/miniconda3/etc/profile.d/conda.sh"
            CONDA_CHANGEPS1=false conda activate base
    else
            \export PATH="/scratch/XXXXXX/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

编辑2:conda config --show的输出

add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_non_channel_urls: False
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: True
channels:
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
  pkgs/main: https://repo.anaconda.com
  pkgs/free: https://repo.anaconda.com
  pkgs/r: 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/pro"]
  local: []
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/pro
disallowed_packages: []
download_only: False
envs_dirs:
  - /scratch/XXXXXX/miniconda3
  - /scratch/XXXXXX/miniconda3/envs
  - /home/XXXXXX/.conda/envs
extra_safety_checks: False
force: False
json: False
local_repodata_ttl: 1
max_shlvl: 2
migrated_channel_aliases: []
no_dependencies: False
non_admin_enabled: True
notify_outdated_conda: True
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pkgs_dirs:
  - /scratch/XXXXXX/miniconda3/pkgs
  - /home/XXXXXX/.conda/pkgs
proxy_servers: {}
quiet: False
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
report_errors: None
rollback_enabled: True
safety_checks: warn
shortcuts: True
show_channel_urls: None
ssl_verify: True
track_features: []
use_index_cache: False
use_pip: True
verbosity: 0
whitelist_channels: []

1 个答案:

答案 0 :(得分:0)

您可能已经解决了,但仅供参考,这是我的操作方法。

基本上,当环境位于自定义路径(例如您的情况下为/scratch/XXXXXX/miniconda3)时,conda会提示完整路径。要使其仅提示环境名称,请在默认路径(/scratch/XXXXXX/miniconda3/envs)上移动(或复制)环境目录,然后从.condarc删除自定义路径。