Running Python Script Placed In Path (cygwin)
I want to place my Python script into directory listed in PATH and call that script just by typing its name from any location in cygwin on Windows. I'm using shebang #!/usr/bin/en
Solution 1:
You're running
C:\app\Python36\python.exe
which is some native Windows Python, and not the Python from Cygwin, compiled to use Cygwin. So naturally it would have no clue about Cygwin paths.
If you want to use Python from Cygwin the best option is to just use the Python that comes with Cygwin.
If you absolutely must use a native Windows Python from Cygwin (you can do this, and I've occasionally had reason to, such as testing code intended to run on Python for Windows that uses the msvcrt module for example) you can do that. But you still need to convert any filesystem paths to a native Windows path. In Cygwin you can do this with the cygpath command like
$ cygpath -w -a /cygdrive/d/whatever
D:\whatever
Wrap any file paths passed to Python like
$ C:/Python36/python.exe "$(cygpath -w -a /cygdrive/d/whatever)"
If you need to do this frequently you can make a wrapper script.
Post a Comment for "Running Python Script Placed In Path (cygwin)"