Python Zsh:未找到 Conda/Pip 安装命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31615322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Zsh: Conda/Pip installs command not found
提问by Architek1
So I installed Anacondaand everything is working. After I installed it I decided to switch to oh-my-zsh
. I am now getting:
所以我安装了Anaconda,一切正常。安装后我决定切换到oh-my-zsh
. 我现在得到:
zsh: command not found: conda
when trying to use pip
or conda
installs
尝试使用pip
或conda
安装时
echo $ZSH_VERSION
5.0.5
5.0.5
I have added to my zshenv.sh
我已经添加到我的 zshenv.sh
export PATH ="/Users/Dz/anaconda/bin:$PATH"
What is it that I'm missing?
我错过了什么?
采纳答案by Architek1
It appears that my PATH is broken in my .zshrc
file.
我的.zshrc
文件中的PATH 似乎已损坏。
Open it and add :
打开它并添加:
export PATH="$PATH;/Users/Dz/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/Dz/.rvm/bin"
Doh! Well that would explain everything. How did I miss that little semicolon? Changed:
哦!那么这将解释一切。我怎么错过了那个小分号?更改:
export PATH="$PATH:/Users/Dz/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/Dz/.rvm/bin"
source ~/.zshrc
echo $HOME
echo $PATH
We're good now.
我们现在很好。
回答by n1tk
As of today Nov 4, 2018 all the following methods works, install the zsh with:
截至今天 2018 年 11 月 4 日,以下所有方法均有效,请使用以下命令安装 zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Notrecommending brew installation for zsh:
不建议为 zsh 安装 brew:
brew install zsh zsh-completions
P.S: Tried with with brew and brew install under the root and is not an wise idea to do so due the security and all time anything related will need to be started under sudo so better is to stick with curlor wget.
PS:尝试在根目录下使用 brew 和 brew install ,但出于安全考虑,这样做并不是一个明智的主意,并且所有相关的事情都需要在 sudo 下启动,所以最好坚持使用curl或wget。
to make work conda in OS X with oh-my-zsh installed is to add path as following and will work.
在安装了 oh-my-zsh 的 OS X 中使用 conda 是添加如下路径并且可以工作。
Find the python paths so can see if you installed Anaconda2 or Anaconda3:
where python
orwhich python
will result in similar output:
找到 python 路径,以便查看您是否安装了 Anaconda2 或 Anaconda3:
where python
或which python
将导致类似的输出:
/usr/bin/python
/Users/"username"/anaconda3/bin/python
/usr/bin/python
Finding your Anaconda Python interpreter path
vi ~/.zshrc orgedit ~/.zshrc
For Anaconda: at field
# User configuration
add:
PATH="$HOME/anaconda/bin:$PATH"
For Anaconda2 at field
# User configuration
add:
PATH="$HOME/anaconda/bin:$PATH"
For Anaconda3 at field
# User configuration
add:
PATH="$HOME/anaconda3/bin:$PATH"
or replace "username" with your username:
PATH="/Users/"username"/anaconda3/bin:$PATH
vi ~/.zshrc或gedit ~/.zshrc
对于 Anaconda:在字段中
# User configuration
添加:
PATH="$HOME/anaconda/bin:$PATH"
对于 Anaconda2 在现场
# User configuration
添加:
PATH="$HOME/anaconda/bin:$PATH"
对于 Anaconda3 在现场
# User configuration
添加:
PATH="$HOME/anaconda3/bin:$PATH"
或用您的用户名替换“用户名”:
PATH="/Users/"username"/anaconda3/bin:$PATH
According to documentation Installing on macOSwe add add in
~/.zshrc
instead of.bashrc or .bash_profile
Add export
PATH="/<path to anaconda>/bin:$PATH"
in ~/.zshrcOr set the PATH variable:
export PATH="/<path to anaconda>/bin:$PATH"
Replace
“<path to anaconda>”
with the actual path to your Anaconda installation.This methods are working on ubuntu/Centos7/MacOS as well (just close/reset the terminal once you are completing the changes) than just type condato test.
根据在 macOS 上安装的文档,我们添加了 add in
~/.zshrc
而不是.bashrc or .bash_profile
PATH="/<path to anaconda>/bin:$PATH"
在 ~/.zshrc 中添加导出或者设置 PATH 变量:
export PATH="/<path to anaconda>/bin:$PATH"
替换
“<path to anaconda>”
为 Anaconda 安装的实际路径。这种方法也适用于 ubuntu/Centos7/MacOS(只需在完成更改后关闭/重置终端),而不仅仅是键入conda进行测试。
Per @truongnm comment just source after adding the path: "I pasted the path from my bash_profile, and don't forget to
source ~/.zshrc
"
每@truongnm 评论只是添加路径后的来源:“我从我的 bash_profile 中粘贴了路径,不要忘记
source ~/.zshrc
”
回答by SwimBikeRun
You need to fix the spacing and quotes:
您需要修复间距和引号:
export PATH ="/Users/Dz/anaconda/bin:$PATH"
Instead use
而是使用
export PATH="/Users/Dz/anaconda/bin":$PATH
回答by ChairmanMeow
FYI for anyone having this same issue keep in mind that you need to make sure that you have the right version of anaconda in that export path:
对于遇到同样问题的任何人,仅供参考,请记住,您需要确保在该导出路径中拥有正确版本的 anaconda:
anaconda2 or anaconda3
Spent way too long on that minor issue.
在那个小问题上花了太长时间。
回答by Johannes Gontrum
The anaconda installer automatically writes the correct PATH into the ~/.bash_profile file. Copy the line to your ~/.zshrc file, source it with source ~/.zshrc
and you're good to go.
anaconda 安装程序会自动将正确的 PATH 写入 ~/.bash_profile 文件。将该行复制到您的 ~/.zshrc 文件中,使用它来获取它,source ~/.zshrc
您就可以开始了。
回答by Smittie
I just ran into the same problem. As implicitly stated inside the .zshrc-file (in your user-root-folder), you need to migrate the pathes you've already inserted in your .bash_profile, bashrc or so to resolve this.
我刚刚遇到了同样的问题。正如 .zshrc 文件(在您的用户根文件夹中)中隐式所述,您需要迁移您已经插入到 .bash_profile、bashrc 等中的路径来解决这个问题。
Copying all additional pathes from .bash_profile to .zshrc fixed it for me, cause zsh now knows where to look.
将所有其他路径从 .bash_profile 复制到 .zshrc 为我修复了它,因为 zsh 现在知道在哪里查找。
#add path to Anaconda-bin
export PATH="/Users/YOURUSERNAME!!/anaconda3/bin:$PATH"
#N.B. for miniconda use
export PATH="/Users/YOURUSERNAME!!!/miniconda3/bin:$PATH"
Depending on where you installed anaconda this path might be different.
根据您安装 anaconda 的位置,此路径可能会有所不同。
回答by Calvin Duy Canh Tran
Find the right version of your
anaconda
Put it to
~/.zshrc
via commandvim ~/.zshrc
- Anaconda 2
export PATH="/User/<your-username>/anaconda2/bin:$PATH"
- Anaconda 3
export PATH="/User/<your-username>/anaconda3/bin:$PATH"
- Or if you install Anaconda in root directory:
- Anaconda 2
export PATH="/anaconda2/bin:$PATH"
- Anaconda 3
export PATH="/anaconda3/bin:$PATH"
- Anaconda 2
Restart the zsh
source ~/.zshrc
找到合适的版本
anaconda
~/.zshrc
通过命令将其放入vim ~/.zshrc
- 蟒蛇2
export PATH="/User/<your-username>/anaconda2/bin:$PATH"
- 蟒蛇3
export PATH="/User/<your-username>/anaconda3/bin:$PATH"
- 或者,如果您在根目录中安装 Anaconda:
- 蟒蛇2
export PATH="/anaconda2/bin:$PATH"
- 蟒蛇3
export PATH="/anaconda3/bin:$PATH"
- 蟒蛇2
重启zsh
source ~/.zshrc
回答by colby-ham
This is all I had to add to add get anaconda working for zsh.
这就是我必须添加的所有内容,才能添加 get anaconda 为 zsh 工作。
echo ". /anaconda3/etc/profile.d/conda.sh" >> ~/.zshrc
source ~/.zshrc
回答by Benchur Wong
I found an easy way. you can try to test it.
我找到了一个简单的方法。你可以尝试测试一下。
Just follow below steps as I show:
只需按照我展示的以下步骤操作:
First, in terminal, enter
首先,在终端输入
vim ~/.zshrc
add
添加
source ~/.bash_profile
into .zshrc file
进入 .zshrc 文件
and then in terminal, enter
然后在终端输入
source ~/.zshrc
Congratulation for you.
祝贺你。
回答by therealnoobcoder
I had this problem on my Catalina OSX after I installed my Anaconda distribution as well.
安装 Anaconda 发行版后,我在 Catalina OSX 上也遇到了这个问题。
This solution worked for me on macOS Catalina as of October 19, 2019
截至 2019 年 10 月 19 日,此解决方案在 macOS Catalina 上对我有用
Step 1. Check if .bash_profile is available on your home folder, if not:
步骤 1. 检查 .bash_profile 在您的主文件夹中是否可用,如果没有:
- Go to Terminal
- Type?
cd ~/
?to go to your home folder (if you are not on your home folder) - Type?
touch .bash_profile
?to create your new file under the your home folder
- 前往终端
- 类型?
cd ~/
?转到您的主文件夹(如果您不在主文件夹中) - 类型?
touch .bash_profile
?在您的主文件夹下创建新文件
Step 2. Check if file .zshrc
is available on your home folder, if not:
第 2 步。检查文件.zshrc
是否在您的主文件夹中可用,如果没有:
Go to terminal and type
nano ~/.zshrc
Type in the following line into the newly created .zshrc file:
source ~/.bash_profile
Now to save the file in?nano?just hit?
ctrl
+X
.It will prompt "Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES)?". Just type in
Y
转到终端并输入
nano ~/.zshrc
在新创建的 .zshrc 文件中输入以下行:
source ~/.bash_profile
现在将文件保存在?纳米?刚打?
ctrl
+X
。它会提示“保存修改后的缓冲区(回答“否”会破坏更改)?” . 只需输入
Y
Step 3. Check if .bash_profile and .zshrc files are created on your home folder. If yes, in terminal type in source ~/.zshrc
步骤 3. 检查是否在您的主文件夹中创建了 .bash_profile 和 .zshrc 文件。如果是,在终端输入source ~/.zshrc