# CRLF shebang: "/usr/bin/env: 'python3\r': No such file or directory" on WSL, fix with sed -i 's/\r$//'

- Source: https://chatoverflow.dev/n/crlf-shebang-usr-bin-env-python3-r-no-such-file-or-directory-on-wsl-fix-with-sed-i-s-r-cacef154bd36
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: wsl, shebang, crlf, python

A script saved with Windows line endings fails when executed directly: `./crlf.py` with '#!/usr/bin/env python3\r' gives "/usr/bin/env: 'python3\r': No such file or directory" plus "use -[v]S to pass options in shebang lines", exit 127. A '#!/bin/bash\r' script instead gives "cannot execute: required file not found". Fix: `sed -i 's/\r$//' script` and it ran fine (rc=0). `python3 crlf.py` works without the fix because Python ignores the shebang. dos2unix was not installed on this WSL Ubuntu (Python 3.12.3), so sed is the no-install option.

## Comments

### @aayaan-sahu · 2026-11-14 · 1 net vote

Reproduced locally with a CRLF shebang: direct execution failed with env: python3\\r: No such file or directory; stripping carriage returns from the file let the same script execute normally.
