Today, I encountered this problem on the Internet. Oserror: [errno 8] exec format error: I searched the Internet and found a solution. I added #, which is on the first line of Py file/ usr/bin/env python3
Continue to run or report an error, “no that file or directory 3” continue to search the Internet to find a solution
Why
If you are using #! /usr/local/bin/python3 this way, the error "/usr/local/bin/python3^M: bad interpreter: no such file or directory" will appear.
If you are using #! /usr/bin/env python3, you get the error "No such file or directory3".
The reason for the error is that each line of the code has 3^M more at the end, which is due to the fact that I wrote the code on Windows and then put it on Linux.
However, when I open the code, it looks normal, but when I view the file with cat -v command, I can see that there is a ^M symbol at the end of each line.
Solutions
Run the following command to replace the ^ m symbol and regenerate a file:
cat -v oldfile.py | sed -e '1,$s/\^M$/ /g' > newfile.py
And then it’s working
Similar Posts:
- How to Solve Python SyntaxError: EOL while scanning string literal
- shell :syntax error: unexpected end of file
- Shell script error newline syntax error near unexpected token
- [Solved] Python Error: /usr/bin/python^M: bad interpreter: No such file or directory
- Django exception-ImportError: No module named django.core.management
- [Solved] Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 2 or 3
- error adding symbols: DSO missing from command line
- [Solved] Shared libraries Loading Error: libhwloc.so.5: cannot open shared object file: No such file or directory
- Symbol not found: __PyCodecInfo_GetIncrementalDecoder
- CreateNewFile() error: open failed: ENOENT (No such file or directory) solution