Python script gives `: No such file or directory`

前端 未结 4 972
渐次进展
渐次进展 2020-11-29 02:36

I have several python scripts which work just fine but one script has (as of this morning) started giving me this error if I try to run it from the bash:

4条回答
  •  佛祖请我去吃肉
    2020-11-29 02:43

    From the comments above it looks like you have dos line endings, and so the hashbang line is not properly processed.

    Line ending style are not shown with :set list in Vim because that option is only used when reading/writing the file. In memory line endings are always that, line-endings. The line ending style used for a file is kept in a Vim per-file option, weirdly called fileformat.

    To see/change the line ending style from Vim, you can use the following commands:

    :set fileformat
    :set ff
    

    It will show dos or unix. You want unix, of course ;-).

    To change it quickly you can save the file with:

    :w ++ff=unix
    

    Or if you prefer:

    :set ff=unix
    

    And then save the file normally.

    So see all the gory details just do :help fileformat, :help file-formats and :help fileformats

提交回复
热议问题