問題描述
我已經(jīng)安裝了 Anaconda 并將 Path 環(huán)境變量設(shè)置為 C:Anaconda3;C:Anaconda3Scripts
.
I've installed Anaconda and set Path environment variable to C:Anaconda3; C:Anaconda3Scripts
.
然后我嘗試在 Git Bash 中運行
Then I try to run in Git Bash
conda 安裝 python
但是有一個錯誤信息bash: conda: command not found".我想知道為什么.
But there is an error message "bash: conda: command not found". I would like to know why.
推薦答案
為了能夠在 gitbash 上運行 conda,您需要將其添加到路徑中.很多時候我看到這是默認(rèn)完成的 - 如本次研討會的設(shè)置所示.如果沒有,就像您的情況一樣,那么您可以通過運行直接運行他們的設(shè)置:
To be able to run conda on gitbash you need to add it to the path. Many times I've seen that's done by default - as shown in the setup for this workshop. If it doesn't, as it seems your case, then you can run their setup directly by running:
. /c/Anaconda3/etc/profile.d/conda.sh
運行之后你應(yīng)該可以運行 conda 命令了.
After running that you should be able to run conda commands.
要永久保留此設(shè)置,您可以在 .profile
或 .bashrc
文件 (閱讀更多關(guān)于它們的差異).這樣做的一種方法是運行以下內(nèi)容:
To keep this setup permanently you can add such line on your .profile
or .bashrc
file (read more about their differences). A way of doing so is running the follwing:
echo ". /c/Anaconda3/etc/profile.d/conda.sh" >> ~/.profile
如果安裝 Anaconda 的路徑包含空格(例如、C:Program Files
),您可能會遇到問題.在這種情況下,您需要更改 anaconda 位置或編輯 conda.sh
腳本,例如:
You may encounter problems if the path where Anaconda was installed contains spaces (e.g., C:Program Files
). In that case you would need to change the anaconda location or edit conda.sh
script with something like:
sed -e '/^_CONDA_EXE=.*/a alias myconda="${_CONDA_EXE/ /\\ }"'
-e 's/$_CONDA_EXE/myconda/g' /c/Program Files/Anaconda3/etc/profile.d/conda.sh > conda_start.sh
這個 sed 命令插入一個新的別名定義 myconda
,它將 anaconda 路徑從 Program Files
更改為 Program Files
,因此 bash 不會停止這樣的錯誤:
This sed command inserts a new alias definition myconda
which changes the anaconda path from Program Files
to Program Files
so bash doesn't stop with an error like this one:
bash: /c/Program: No such file or directory
第二個 sed 命令用創(chuàng)建的新別名替換 _CONDA_EXE
變量.
The second sed command replaces the _CONDA_EXE
variable by the new alias created.
由于上面沒有修改anaconda提供的文件,你需要更新你的.profile
文件來加載我們剛剛創(chuàng)建的文件conda_start.sh代碼>,而不是.
Since the above doesn't modify the file provided by anaconda, you will need to update your .profile
file to load the file we've just created, conda_start.sh
, instead.
這篇關(guān)于Windows 中的 Anaconda 和 Git Bash - conda: command not found的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!