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

890 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.