pipenv
has no special option for it. But you can use these bash scripts (I made them using the venvs directory ~/.local/share/virtualenvs/
so you should change it if your venvs folder is different)
PRINT useless venvs:
for f in $(find ~/.local/share/virtualenvs/*/.project -type f); do proj_path="$(cat $f)" && [ ! -d "$proj_path" ] && echo ${f//\/.project}; done;
PRINT not existing projects paths that still have corresponding venvs:
for f in $(find ~/.local/share/virtualenvs/*/.project -type f); do proj_path="$(cat $f)" && [ ! -d "$proj_path" ] && echo $proj_path; done;
PRINT both (useless venvs and not existing project folders):
for f in $(find ~/.local/share/virtualenvs/*/.project -type f); do proj_path="$(cat $f)" && [ ! -d "$proj_path" ] && echo $proj_path "\n"${f//\/.project} "\n"; done;
DELETE useless venvs
for f in $(find ~/.local/share/virtualenvs/*/.project -type f); do proj_path="$(cat $f)" && [ ! -d "$proj_path" ] && rm -rif ${f//\/.project} && echo DELETING ${f//\/.project}; done;
Try printing the venvs before deleting!
p.s. If your venv folder is not ~/.local/share/virtualenvs/
, make sure to change it to your venv path!