zsh:找不到命令:flake8 但已安装 flake8 [英] zsh: command not found: flake8 but flake8 is installed

查看:70
本文介绍了zsh:找不到命令:flake8 但已安装 flake8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Python 代码上运行 flake8 linter,但我遇到了一些问题.

I'm trying to run the flake8 linter on my python code but I am having some issues.

运行 pip install 给了我这个响应:

running pip install gives me this response:

~ pip install flake8                                                                                                                                                                                                                                  
Requirement already satisfied: flake8 in ./Library/Python/2.7/lib/python/site-packages
Requirement already satisfied: enum34; python_version < "3.4" in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: configparser; python_version < "3.2" in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: pycodestyle<2.4.0,>=2.0.0 in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: pyflakes<1.6.0,>=1.5.0 in ./Library/Python/2.7/lib/python/site-packages (from flake8)

但是当我尝试运行它时出现此错误.

but then when I try to run it I get this error.

~ flake8 --version                                                                                                                                                                                                                                    
zsh: command not found: flake8

如果这有什么不同的话,我也在使用 mac.

I am using a mac as well if that makes any difference.

请任何人帮忙.

推荐答案

flake8 脚本不在您的路径中.

The flake8 script isn't in your path.

首先弄清楚它的安装位置:

First figure out where it's installed:

pip show -f flake8

您应该看到安装位置,通常以 site-packages 结尾,然后是文件列表 - 其中之一可能类似于 ../../bin/flake8.将相对路径应用于安装位置,您将找到可执行文件的路径.

You should see the install location, usually something ending in site-packages, and then the list of files - one of which may look like ../../bin/flake8. Apply the relative path to the install location and you'll find the executable's path.

如果您在 mac 上使用 Homebrew,则可执行文件很有可能位于 /usr/local/bin 下,但无论如何您都需要将该目录添加到您的 PATH(在zsh中搜索add directory to path")或指定完整路径.

If you're using Homebrew on mac, there's a good chance the executable sits under /usr/local/bin, but in any case you need to add that directory to your PATH (search for "add directory to path in zsh") or specify the full path.

最后,如果路径在 PATH 中,但仍然没有找到,而您刚刚将其添加到路径中,请考虑运行 rehash,它会在当前 PATH 中重建 zsh 的可执行文件的哈希值.

Finally, if the path is in PATH and it still doesn't find it, and you added it to the path just now, consider running rehash which rebuilds zsh's hash of executables in the current PATH.

这篇关于zsh:找不到命令:flake8 但已安装 flake8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆