我有一些我经常在 windows(cygwin) 和 linux 中使用的脚本,我想让这些脚本在这两种环境中都可以执行。有没有办法为我的 python 安装位置设置别名,例如这样
#!/usr/bin/python
仍然会找到我的 python 安装,即使就 cygwin 而言,它位于/cygdrive/c/Python26/python
?
将 /cygdrive/c/Python26/python 放入 PATH 变量中,并将 shebang 行替换为
#!/usr/bin/env python
假设 cygwin 可以运行该版本的 python。
只需通过 Cygwin 安装 Python setup.exe
,它就会在/usr/bin
.
或者在两个系统上创建符号链接,例如在 中/usr/local/bin/python
,并在 shebang 中使用它。
或者编写一个安装脚本,#!
在安装 Python 脚本时调整它们的行。
请注意,如果您的/cygdrive/c/Python26/python
( C:\Python26\python
) 是本机 Windows Python 安装,则使用它的脚本将无法使用 Cygwin 样式的路径。