【发布时间】:2011-08-20 10:24:07
【问题描述】:
在 Windows 上运行已安装的脚本时出现问题,如下所示
C:\Users\Piotr>where python
C:\program files\Python\2.7\python.exe
C:\Users\Piotr>python c:\program files\Python\2.7\scripts\ve init
[Errno 2] No such file or directory
Is "ve-init" executable in the current path?
C:\Users\Piotr>
我尝试按照How to run installed python script? 问题中的建议解决此问题,但没有成功:
C:\Users\Piotr>assoc .py
.py=Python.File
C:\Users\Piotr>ftype Python.File
Python.File=c:\program files\Python\2.7\python.exe "%1" %*
C:\Users\Piotr>dir /b "c:\program files\python\2.7\scripts"
easy_install-2.7-script.py
easy_install-2.7.exe
easy_install-script.py
easy_install.exe
pip-2.7-script.py
pip-2.7.exe
pip-script.py
pip.exe
ve-clone
ve-extend
ve-init.py
ve.py
virtualenv-script.py
virtualenv.exe
C:\Users\Piotr>python c:\program files\Python\2.7\Scripts\ve.py init
[Errno 2] No such file or directory
Is "ve-init" executable in the current path?
我认为这种情况下的特别之处在于ve 脚本通过操作系统(os.execvp())运行命令脚本(ve-init、ve-clone 等)。
【问题讨论】:
-
我阅读了您链接到的帖子。在我看来你没有按照它的指示行事?您需要
ve-init才能被 Windows 运行。如果不是ve-init.py和正确的文件关联,windows 怎么知道如何运行它? -
我遵循了这些说明,但不想让我的问题太长,所以我跳过了结果。现在我将它们添加到我的问题中。
-
在我看来,当您需要运行
ve-init.py时,您仍然在尝试运行ve-init——该列表中没有ve-init。即使有了关联,您仍然需要完整的文件名吗? -
对,这就是
ve脚本的作用(command = 've-%s' % command然后return os.execvp(command, (command, ) + args)。我将不得不修改这些脚本,如果有其他方法可以得到,我想避免这样做它工作。 -
没有任何方法可以在 Windows 上执行此操作,除非您在 MSYS 中使用 bash 或可以解释文件开头的 hashbang 的东西。否则,您需要文件具有
.py扩展名或显式调用python。
标签: python windows exec virtualenv virtualenv-commands