I'm trying sudo find . -type d -name '__pycache__' -delete as found here https://github.com/python-mode/python-mode#how-to-install on the trouble shooting page of python-mode. The terminal returns: find: cannot delete 'path' : directory not empty.

Is there a way to work around this. It surprises me this doesn't work as it is literally in the python-mode README.

I'm on Fedora 29 workstation.


you could do

sudo find . -type d -name '__pycache__' -exec rm -rf {} \;

or work with xargs

sudo find . -type d -name 'test' | sudo xargs rm -rf

You can use the exec option of find to use an external command to handle the delete such as rm -rf.


sudo find . -type d -name '__pycache__' -exec rm -rf "{}" \;

Note: the {} is a placeholder for the file path and \; ends the exec command. See man 1 find for more details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.