提示括号(myenv)$在最新的conda中似乎消失了

时间:2019-03-16 14:03:15

标签: linux bash anaconda conda ubuntu-18.04

提示括号(myenv)$在最新的conda中似乎消失了。

当前情况:

john@myPC:~$ conda activate myenv
john@myPC:~$ 

应该是:

john@myPC:~$ conda activate myenv
(myenv) john@myPC:~$ 

到目前为止我尝试过和失败的事情。

解决方案A:

$ conda config // init .condarc file
$ conda config --set changeps1 True

然后重新登录bash,不起作用

解决方案B:

put `changeps1: true` in `.condarc` file

解决方案C:

put `export CONDA_CHANGEPS1=true` in `.bashrc`

请给我一些建议。

操作系统:ubuntu 18.04

Anaconda安装程序:64-Bit (x86) Installer - Anaconda3-2018.12-Linux-x86_64.sh 终端:GNU bash,版本4.4.19

这是我的conda info

$ rm ~/.condarc
$ conda init --dry-run -vv
DEBUG conda.gateways.logging:set_verbosity(150): verbosity set to 2
DEBUG conda.gateways.subprocess:subprocess_call(48): executing>> /home/{user}/anaconda3/bin/python --version


/home/{user}/.bashrc
--- 

+++ 

@@ -129,7 +129,7 @@

     \eval "$__conda_setup"
 else
     if [ -f "/home/{user}/anaconda3/etc/profile.d/conda.sh" ]; then
-        . "/home/{user}/anaconda3/etc/profile.d/conda.sh"
+# . "/home/{user}/anaconda3/etc/profile.d/conda.sh"  # commented out by conda initialize
         CONDA_CHANGEPS1=false conda activate base
     else
         \export PATH="/home/{user}/anaconda3/bin:$PATH"
@@ -150,3 +150,19 @@

 ##############################
 export PATH=/usr/local/cuda-9.2/bin:/usr/lib/nvidia-396:${PATH:+:${PATH}}
 export LD_LIBRARY_PATH=/usr/lib/nvidia-396:/usr/local/cuda-9.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
+
+# >>> conda initialize >>>
+# !! Contents within this block are managed by 'conda init' !!
+__conda_setup="$('/home/{user}/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
+if [ $? -eq 0 ]; then
+    eval "$__conda_setup"
+else
+    if [ -f "/home/{user}/anaconda3/etc/profile.d/conda.sh" ]; then
+        . "/home/{user}/anaconda3/etc/profile.d/conda.sh"
+    else
+        export PATH="/home/{user}/anaconda3/bin:$PATH"
+    fi
+fi
+unset __conda_setup
+# <<< conda initialize <<<
+
no change     /home/{user}/anaconda3/condabin/conda
no change     /home/{user}/anaconda3/bin/conda
no change     /home/{user}/anaconda3/bin/conda-env
no change     /home/{user}/anaconda3/bin/activate
no change     /home/{user}/anaconda3/bin/deactivate
no change     /home/{user}/anaconda3/etc/profile.d/conda.sh
no change     /home/{user}/anaconda3/etc/fish/conf.d/conda.fish
no change     /home/{user}/anaconda3/shell/condabin/Conda.psm1
no change     /home/{user}/anaconda3/shell/condabin/conda-hook.ps1
no change     /home/{user}/anaconda3/lib/python3.7/site-packages/xonsh/conda.xsh
no change     /home/{user}/anaconda3/etc/profile.d/conda.csh
modified      /home/{user}/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

john@myPC:~$ conda info

     active environment : base
    active env location : /home/john/anaconda3
            shell level : 1
       user config file : /home/john/.condarc
 populated config files : 
          conda version : 4.6.8
    conda-build version : 3.17.6
         python version : 3.7.1.final.0
       base environment : /home/john/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/john/anaconda3/pkgs
                          /home/john/.conda/pkgs
       envs directories : /home/john/anaconda3/envs
                          /home/john/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.8 requests/2.21.0 CPython/3.7.1 Linux/4.15.0-46-generic ubuntu/18.04.2 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
john@myPC:~$ conda config
john@myPC:~$ cat .condarc
{}
john@myPC:~$ conda activate myenv
john@myPC:~$ conda info

     active environment : molhack
    active env location : /home/john/anaconda3/envs/molhack
            shell level : 2
       user config file : /home/john/.condarc
 populated config files : 
          conda version : 4.6.8
    conda-build version : 3.17.6
         python version : 3.7.1.final.0
       base environment : /home/john/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/john/anaconda3/pkgs
                          /home/john/.conda/pkgs
       envs directories : /home/john/anaconda3/envs
                          /home/john/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.8 requests/2.21.0 CPython/3.7.1 Linux/4.15.0-46-generic ubuntu/18.04.2 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
john@myPC:~$ conda config --set changeps1 True
john@myPC:~$ cat ~/.condarc
changeps1: true
john@myPC:~$
// 
// (myenv)john@myPC:~$ are missing
//

1 个答案:

答案 0 :(得分:0)

conda init的输出很奇怪。在正确配置的安装中,它应该显示no change,但是您的安装表明它会更改您的.bashrc。您可以尝试让conda init完成其工作,但是,建议的更改似乎表明这将导致多个Conda管理区域。相反,我会尝试

  1. 备份.bashrc
  2. .bashrc删除任何Conda管理的部分。另外,请确保没有将/home/{user}/anaconda3/bin添加到路径的任何部分(根据v4.4 recommendations)。
  3. 运行conda init -vv。标记就在那里查看其作用。
  4. 启动一个新的bash shell。