env: python\r: No such file or directory
问题 My Python script beak contains the following shebang: #!/usr/bin/env python When I run the script $ ./beak , I get env: python\r: No such file or directory I previously pulled this script from a repository. What could be the reason for this? 回答1: The script contains CR characters. The shell interprets these CR characters as arguments. Solution: Remove the CR characters from the script using the following script. with open('beak', 'rb+') as f: content = f.read() f.seek(0) f.write(content