简体   繁体   中英

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

ImportError: cannot import name 'grep' from 'plumbum.cmd' (unknown location)

I tried installing the module in Anaconda using conda install plumbum and it did install. 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.

That error means plumbum was unable to find those commands in your PATH.

Try adding your unix util folder to your PATH.

Or modifying your path before importing from 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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