shebang line not working

橙三吉。 提交于 2019-12-04 01:24:20

问题


Don't know what's wrong with my shebang line:

vic@ubuntu:~/Desktop$ ./test.py 
: No such file or directory

vic@ubuntu:~/Desktop$ ls -l
...
-rwxr-xr-x  1 vic vic        35 2011-11-06 15:46 test.py
...

vic@ubuntu:~/Desktop$ cat test.py 
#!/usr/bin/env python
print('!')

vic@ubuntu:~/Desktop$ /usr/bin/env python
Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Any ideas?

vic@ubuntu:~/Desktop$ head -n 2 test.py|hexdump -C
00000000  23 21 2f 75 73 72 2f 62  69 6e 2f 65 6e 76 20 70  |#!/usr/bin/env p|
00000010  79 74 68 6f 6e 0d 0a 0d  0a                       |ython....|
00000019
vic@ubuntu:~/Desktop$

回答1:


Your file has Windows-type line endings. Convert it to proper Unix-type line endings and you should be good to go.

$ dos2unix test.py


来源:https://stackoverflow.com/questions/8027447/shebang-line-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!