0

There's a problem with running installed scripts on Windows which can be seen below

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>

I tried to resolve this by following advices in How to run installed python script? question but with no luck:

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?

I think what's special in this case is that ve script runs command scripts (ve-init, ve-clone etc.) through OS (os.execvp()).

Community
  • 1
  • 1
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
  • I read the post you linked to. It doesn't look to me like you followed its instructions? You need `ve-init` to be runnable by windows. How does windows know how to run it if it's not `ve-init.py` with the correct file association? – agf Aug 20 '11 at 17:14
  • I followed these instructions but didn't want to make my question too long so I skipped results. Now I added them to my question. – Piotr Dobrogost Aug 21 '11 at 20:32
  • It still looks to me like you're trying to run `ve-init` when you need to be running `ve-init.py` -- there is no `ve-init` in that list. Even with the association you still need the full file name? – agf Aug 21 '11 at 21:12
  • Right, that's what `ve` script does (`command = 've-%s' % command` and then `return os.execvp(command, (command, ) + args)`. I would have to modify these scripts and I'd like to avoid doing this if there's some other way to get it working. – Piotr Dobrogost Aug 21 '11 at 21:31
  • There isn't any way to do this on windows, unless you're using bash in MSYS or something that can interpret the hashbang at the beginning of the file. Otherwise you need the files to have the `.py` extension or call `python` explicitly. – agf Aug 21 '11 at 21:34

1 Answers1

0

The solution is to add .py extension to PATHEXT environment variable so that Python scripts could be run without specifying extension (as long as they are on the PATH).

Nevertheless this is not enough to get virtualenv-commands working on Windows because this package uses Unix specific tools which are not available on Windows.

Funny, I guess the idea behind creating virtualenv-commands was to make it more portable than virtualenvwrapper by not using shell scripts but it seems current implementation supports only Unix.

Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366