Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jeflopodev opened this issue Jun 1, 2015 · 1 comment
Open

Comments

@jeflopodev
Copy link

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
Copy link
Collaborator

thebjorn commented Aug 5, 2017

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..

  • remove the if and just use virtualenv %ARGS% as explained above
  • add to the if statement so it does an exhaustive search of all plausible locations for virtualenv
  • search the path for first executable named virtualenv.xxx (e.g. https://github.com/datakortet/dkfileutils/blob/master/dkfileutils/which.py)
  • allow the user to override with an environment variable (e.g. %VIRTUALENV_EXECUTABLE%)

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants