我的anaconda3是之前安装好了的,同时也能使用conda命令。但就在我使用conda和pip命令安装其他程序后,conda命令失效,
输入:conda --version或者conda list
输出:
RROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
再次输入:pip install conda
输出:
Requirement already satisfied: conda in ./anaconda3/lib/python3.7/site-packages (4.3.16)
Requirement already satisfied: requests>=2.12.4 in ./anaconda3/lib/python3.7/site-packages (from conda) (2.21.0)
Requirement already satisfied: ruamel.yaml>=0.11.14 in ./anaconda3/lib/python3.7/site-packages (from conda) (0.15.89)
Requirement already satisfied: pycosat>=0.6.1 in ./anaconda3/lib/python3.7/site-packages (from conda) (0.6.3)
Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/lib/python3.7/site-packages (from requests>=2.12.4->conda) (2019.3.9)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./anaconda3/lib/python3.7/site-packages (from requests>=2.12.4->conda) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in ./anaconda3/lib/python3.7/site-packages (from requests>=2.12.4->conda) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in ./anaconda3/lib/python3.7/site-packages (from requests>=2.12.4->conda) (1.24.1)
说明我的anaconda3明明在啊
输入:pip --version
输出:pip 9.0.1 from /home/zhongjia/anaconda3/lib/python3.6/site-packages (python 3.6)
说明anaconda3下面的pip命令也是可以用的
于是我想到添加环境变量:
vim ~/.bashrc
添加:
export PATH=/home/zhongjia/anaconda3/bin:$PATH
然后:
source ~/.bashrc
bashrc文件是在用户登录和打开shell读取一次环境变量,所以需要source一次,再次运行conda --version
依然提示:
RROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
最后我觉得重新安装anaconda3,幸好我有Anaconda3-5.1.0-Linux-x86_64.sh没有删除
于是 我:bash Anaconda3-5.1.0-Linux-x86_64.sh
因为我之前conda命令安装了好些程序,还有虚拟环境,我怕重新安装anaconda3后之前的一切都需要重新安装,那是很崩溃的!
所以我想到在之前安装anaconda3的目录下覆盖安装一次,但是使用bash Anaconda3-5.1.0-Linux-x86_64.sh命令会提示原目录下已经存在anaconda3,无法安装,或者选择其他目录安装。当然不愿意!所以强制安装命令:
bash Anaconda3-5.1.0-Linux-x86_64.sh -f
这样就OK了!
虽然安装过程中很担心之前的安装的东西没有了,但是安装完成后,我conda list 发现之前的所有程序都安然无恙!
至此,问题解决了。
但是我还是有疑问,不知道conda 命令为何突然失效,以及添加anconda3到环境变量里面后,依然不能使用conda命令。
因为重新安装anaconda3时也会提示添加环境变量:
Appending source /home/zhongjia/anaconda3/bin/activate to /home/zhongjia/.bashrc
A backup will be made to: /home/zhongjia/.bashrc-anaconda3.bak
这个和我前面添加环境变量是一样的操作啊,但前面却不行。