Created
December 26, 2020 13:03
-
-
Save lonsty/51db07922592dce1f9e89f8d9d644368 to your computer and use it in GitHub Desktop.
Remove broken bin files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7 | |
# @Author: eilianxiao | |
# @Date: Dec 26 19:35 2020 | |
"""删除找不到 Python 解释器的执行文件""" | |
import os | |
import subprocess | |
BIN_DIR = '/usr/local/bin' | |
found = subprocess.run(f'find {BIN_DIR} -type f', shell=True, stdout=subprocess.PIPE) | |
bin_files = found.stdout.decode().split('\n') | |
for bin in bin_files: | |
result = subprocess.run(f'{bin} --help', shell=True, capture_output=True) | |
err = result.stderr.decode() | |
if '/usr/local/opt/[email protected]/bin/python3.9: bad interpreter: No such file or directory' in err: | |
print(exec, err.split('\n')[0]) | |
os.remove(bin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment