davidmarble / virtualenvwrapper-win

Port of Doug Hellmann's virtualenvwrapper to Windows batch scripts
Other
460 stars 106 forks source link

mkvirtualenv.bat - The system cannot find the path specified. #53

Open jeflopodev opened 9 years ago

jeflopodev commented 9 years ago

mkvirtualenv.bat wasn't working for me till I have modified a path in its code.

I'm Using:

Windows 10 Build 10130 x64 python 3.4.3 pip 7.0.1 setuptools 12.0.5 virtualenv 13.0.1 virtualenv-clone 0.2.5 virtualenwrapper 4.5.1 virtualenvwrapper-win 1.2.0

Default UAC Settings.

My %PATH% (not modified manually):

C:\Python34\;C:\Python34\Scripts;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Git\cmd

My %WORKON_HOME%:

C:\virtualenvs

My %PYHOME%:

C:\Python34\

I have modified the else path part (lines 49 to 53) of mkvirtualenv.bat:

if exist "%PYHOME%\Scripts\virtualenv-script.py" (
   python.exe "%PYHOME%\Scripts\virtualenv-script.py" %ARGS%
) else (
   #From "virtualenv.exe %ARGS%" (without quotes) to:
   python.exe "%PYHOME%\Scripts\virtualenv.exe" %ARGS%
)

My *.bat scripts was installed in my base prefix, C:\python34 and not in C:\python34\ And this is why it wasn't working.

I don't know If this is just a workaround or the way to go. But a point, de documentation says to setup %PATH% and %WORKON_HOME%, but the code uses %PYHOME% Shouldn't be the code be using one or the other but not both env vars ? :$

I also think that's very ugly the python.exe "%PYHOME%\Scripts\virtualenv.exe" %ARGS% call. Calling an exe from another exe xd But this is my fault Hehe

workon, deactivate, rmvirtualenv & lsvirtualenv commands work fine after this change.

thebjorn commented 7 years ago

It should be sufficient to use "%PYHOME%\Scripts\virtualenv.exe" %ARGS% (it's an executable..)

%PATH% is in relation to finding the virtualenvwrapper .bat files, %WORKON_HOME% is where your virtualenvs will be stored. %PYHOME% is either copied from PYTHONHOME or sys.exec_prefix and should point to the directory containing python.exe (users should never need to change this to accommodate this project).

The intention of the outer if is to figure out where the virtualenv package placed its entry point, so we can call it, but perhaps we shouldn't worry and just use:

    virtualenv %ARGS%

and leave it up to the user to fix their environment variables..? Most users can probably run virtualenv already so this shouldn't cause problems.

Looking at it (https://github.com/pypa/virtualenv/blob/master/setup.py) a bit closer, virtualenv can place its entry point in different locations depending on the presence of the setuptools package.

Possible solutions..

I don't have a strong opinion either way (but the environment variable override might be a good idea regardless of what else is chosen).