简体   繁体   English

从铅。cmd 进口 git,grep,Z177544AA797AF6F322F322F8CAA5E80E7

[英]from plumbum.cmd import git, grep, sed, wc

ImportError: cannot import name 'grep' from 'plumbum.cmd' (unknown location) ImportError:无法从“plumbum.cmd”(未知位置)导入名称“grep”

I tried installing the module in Anaconda using conda install plumbum and it did install.我尝试使用 conda install plumbum 在 Anaconda 中安装模块,它确实安装了。 Now what I am missing such that the above import do not work.现在我缺少什么,以至于上述导入不起作用。

I used Spyder editor for this but planning to transition soon to Visual Studio Code if that makes any difference.我为此使用了 Spyder 编辑器,但如果这有什么不同,我计划很快过渡到 Visual Studio Code。

That error means plumbum was unable to find those commands in your PATH.该错误意味着铅无法在您的 PATH 中找到这些命令。

Try adding your unix util folder to your PATH.尝试将 unix util 文件夹添加到 PATH。

Or modifying your path before importing from plumbum:或者在从 plumbum 导入之前修改路径:

os.environ["PATH"] = (
    os.path.expanduser("~/scoop/apps/git/current/usr/bin/") + ";" + os.environ["PATH"]
)

from plumbum.cmd import git, grep, sed, wc

I installed git on Windows with scoop, so that adds the unix utils that come with git to my PATH.我用勺子在 Windows 上安装了 git,以便将 unix 实用程序添加到 myPATHFDC 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM