当前位置: 动力学知识库 > 问答 > 编程问答 >

python - where to save a file in cygwin

问题描述:

noobiest question ever:

I'm trying to work with python via cygwin on my pc laptop - I have a file (foo.py) but python can't find it. The error it's giving me is:

$ chmod +x foo.py

chmod: cannot access `foo.py': No such file or directory

Is there a special location within the Cygwin folder that I need to save my foo.py?

Thanks!

AP

网友答案:

It's not python that can't find your file, it's the chmod command. C drive is mapped to /cygdrive/c in Cygwin, and D drive is mapped to /cygdrive/d and so on and so forth.

Are you in the same directory as the file when you are running chmod?

If your file is at C:\mycode\python\foo.py then you should either change to that directory first -

$ cd c:
$ cd mycode/python/

or as @Ahmed mentioned above, you could also run the command as

$ chmod +x /cygdrive/c/mycode/python/foo.py

But you only need chmod if your python script starts with

#!/bin/python

To execute such a file, you'd say

$ /cygdrive/c/mycode/python/foo.py

Or if you are in the same directory

./foo.py

If the first line of the python script isn't "#!/bin/python" then you can skip the chmod and just type

python /cygdrive/c/mycode/python/foo.py
网友答案:

You go right click on foo.py figure out its full path then do this:

chmod +x foos-full-directory/foo.py

And this should work for you and btw its not Python problem it's your pwd other than the foo.py working directory and you even didn't use python word in your command.

分享给朋友:
您可能感兴趣的文章:
随机阅读: