You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: pyenv rehash introduces bug with virtualenvwrapper #287
Describe the bug
I installed pyenv-win, and subsequently installed a new Python with version 3.7. In Python 3.7, I pip-installed virtualenvwrapper-win. Following the instructions on virtualenvwrapper, I tried running a command like mkvirtualenv, which returned "mkvirtualenv is not a recognized command". Then I remembered I had to rehash pyenv after the install, and so did pyenv rehahs. Now running mkvirtualenv gives "Scripts is not a recognized command".
I also tried uninstalling and reinstalling virtualenvwrapper, with rehash right after both uninstall and reinstall, but the same error occurrs (see screenshot).
To Reproduce
Steps to reproduce the behavior:
Install pyenv-win and new Python version, switch to that Python version with pyenv shell 3.7.6. Confirm correct Python version is active.
Install virtualenvwrapper-win via pip install virtualenvwrapper-win
Rehahs pyenv-win with pyenv rehahs
See error
Expected behavior
To be able to run mkvirtualenv <env> or other commands related to virtualenvwrapper
Screenshots
Desktop (please complete the following information):
OS: Windows 10
Tools used: Command Prompt (cmd)
Version: Pyenv-win version 2.64.8
Additional context
I also tried finding the file "virtualenvwrapper.sh", fillowing the instructions on virtualenvwrapper, but that file is nowhere to be found, I only find a "virtualenvwrapper.bat" inside [...]\.pyenv\pyenv-win\versions\3.7.6\Scripts.
virtualenvwrapper-win is a windows implementation of virtualenvwrapper and therefore does not use the virtualenvwrapper.sh file, instead it installs its implementation (a number of .bat files) in the Scripts directory of the system python, e.g.
(dev35) go|c:\Program Files (x86)\Python35-32\Scripts> dir *.bat
Volume in drive C is OS
Volume Serial Number is 4C4D-147C
Directory of c:\Program Files (x86)\Python35-32\Scripts
11/07/2018 12:52 AM 1,805 add2virtualenv.bat
08/05/2017 11:51 PM 83 cd-.bat
11/07/2018 12:52 AM 823 cdproject.bat
08/05/2017 11:51 PM 368 cdsitepackages.bat
08/05/2017 11:51 PM 350 cdvirtualenv.bat
11/07/2018 12:52 AM 495 folder_delete.bat
08/05/2017 11:51 PM 997 lssitepackages.bat
08/05/2017 11:51 PM 267 lsvirtualenv.bat
11/07/2018 12:52 AM 1,601 mkproject.bat
02/16/2020 10:47 PM 9,158 mkvirtualenv.bat
11/07/2018 12:52 AM 1,050 rmvirtualenv.bat
11/07/2018 12:52 AM 2,248 setprojectdir.bat
08/05/2017 11:51 PM 422 toggleglobalsitepackages.bat
11/07/2018 12:52 AM 2,326 virtualenvwrapper.bat
11/07/2018 12:52 AM 1,608 vwenv.bat
11/07/2018 12:52 AM 557 whereis.bat
11/07/2018 12:52 AM 1,495 workon.bat
17 File(s) 25,653 bytes
Could it be that pyenv-win doesn't handle paths with spaces or parenthesis?
Hei Bjorn, thank you for the comment., and for the clarifications about the .bat files in place of the .sh. That made it much clearer :)
I have checked the other issue you linked (which also prompted me to edit the above by specifying I installed pyenv-win). It may be related, but it's hard for me to say.
To give some additional info that you asked in the other issue: I have a Python 3.9 installed "from scratch" with the python.org downloadable, which gave me pip through which I installed pyenv-win, and later the Python 3.7 as described above. virtualenvwrapper-win is installed only in Python 3.7, but at the same time that version is the only one pyenv-win can see, checking with the command pyenv versions.
There are no spaces or parenthesis on the path. The full path to the virtualwrapper executables (.bat) is C:\Users\filippor\.pyenv\pyenv-win\versions\3.7.6\Scripts. As far as I understand reading the doc for pyenv exec, the part of the path up to [...]\3.7.6 is automatically added by the pyenv-win's shims, so that then when I run the command mkvirtualenv, the command actually being run is Scripts\mkvirtualenv. It seems like the Command Prompt interprets the "Scripts" part as the command name, instead of the directory into which to search.
To check if that works, I manually cd myself into C:\Users\filippor\.pyenv\pyenv-win\versions\3.7.6 and then ran Scripts\mkvirtualenv, and the command gets executed normally and I can create the virtualenv. Same goes for other commands given by virtualenvwrapper.
Weirdly, I have checked the shims for, say, pip, and it's made in the same way, but pip works fine. So I am a bit stumbled here.
OK, I can reproduce when I run the command with the wrong Python activated:
C:\Users\ded $ mkvirtualenv
'Scripts' is not recognized as an internal or external command,
operable program or batch file.
Following your steps, mkvirtualenv is only available for one Python version, the one that was activated when pip run.
So this works only when you activate the right Python version.
I'll see what I can do to improve the error (should be something like command not found).
Hi dedale, note that you used pyenv local 3.7.7 instead of pyenv shell as in the issue posted above. See screenshot below, which I just reproduced:
EDIT - After dedale's second answer: It seems to me that the correct Python version is active in the screenshot above, that I verify with pyenv shell; it might be a conflict between the global/local/shell Python versions being used, perhaps? However, both pyenv global and pyenv local return "No global (local) version configured", so the only one active in my shell is the one from pyenv shell, which seems to be the right one.
Describe the bug
I installed pyenv-win, and subsequently installed a new Python with version 3.7. In Python 3.7, I pip-installed virtualenvwrapper-win. Following the instructions on virtualenvwrapper, I tried running a command like mkvirtualenv, which returned "mkvirtualenv is not a recognized command". Then I remembered I had to rehash pyenv after the install, and so did pyenv rehahs. Now running mkvirtualenv gives "Scripts is not a recognized command".
I also tried uninstalling and reinstalling virtualenvwrapper, with rehash right after both uninstall and reinstall, but the same error occurrs (see screenshot).
To Reproduce
Steps to reproduce the behavior:
Install pyenv-win and new Python version, switch to that Python version with pyenv shell 3.7.6. Confirm correct Python version is active.
Install virtualenvwrapper-win via pip install virtualenvwrapper-win
Rehahs pyenv-win with pyenv rehahs
See error
Expected behavior
To be able to run mkvirtualenv <env> or other commands related to virtualenvwrapper
Screenshots
Desktop (please complete the following information):
OS: Windows 10
Tools used: Command Prompt (cmd)
Version: Pyenv-win version 2.64.8
Additional context
I also tried finding the file "virtualenvwrapper.sh", fillowing the instructions on virtualenvwrapper, but that file is nowhere to be found, I only find a "virtualenvwrapper.bat" inside [...]\.pyenv\pyenv-win\versions\3.7.6\Scripts.
To Reproduce
Step 1. Is wrong. Why? find the below explanation. pyenv shell <version> doesn't confirm correct python version. It sets the default python shell to the given version even you configure the pyenv local the python shell (interpreter) uses the default which is configured.
If you wanted to validate the python is set, use following commands pyenv version or pyenv versions or pyenv version-name
To set use following commands pyenv local <version> or pyenv global <version>
Hi Kirankotari,
No, step 1 is correct. pyenv shell <version> sets the version of Python for the current shell. To confirm the active Python version one can then use pyenv shell,i.e. without the <version> argument, as explained in the help function. You can also see this in the screenshot I posted right above your reply. Perhaps I should have been more specific.
After setting the Python version with step 1, the same version (i.e. 3.7.6) is shown as the active one by all of the commands pyenv shell, pyenv version, pyenv version-name, and pyenv versions (marked with a star).
Activity
thebjorn commentedon Jul 19, 2021
Maybe related..? davidmarble/virtualenvwrapper-win#112
virtualenvwrapper-win is a windows implementation of virtualenvwrapper and therefore does not use the virtualenvwrapper.sh file, instead it installs its implementation (a number of .bat files) in the Scripts directory of the system python, e.g.
Could it be that pyenv-win doesn't handle paths with spaces or parenthesis?
filipporemonato commentedon Jul 19, 2021
Hei Bjorn, thank you for the comment., and for the clarifications about the .bat files in place of the .sh. That made it much clearer :)
I have checked the other issue you linked (which also prompted me to edit the above by specifying I installed pyenv-win). It may be related, but it's hard for me to say.
To give some additional info that you asked in the other issue: I have a Python 3.9 installed "from scratch" with the python.org downloadable, which gave me
pipthrough which I installedpyenv-win, and later the Python 3.7 as described above. virtualenvwrapper-win is installed only in Python 3.7, but at the same time that version is the only one pyenv-win can see, checking with the commandpyenv versions.There are no spaces or parenthesis on the path. The full path to the virtualwrapper executables (.bat) is
C:\Users\filippor\.pyenv\pyenv-win\versions\3.7.6\Scripts. As far as I understand reading the doc forpyenv exec, the part of the path up to[...]\3.7.6is automatically added by the pyenv-win's shims, so that then when I run the commandmkvirtualenv, the command actually being run isScripts\mkvirtualenv. It seems like the Command Prompt interprets the "Scripts" part as the command name, instead of the directory into which to search.To check if that works, I manually
cdmyself intoC:\Users\filippor\.pyenv\pyenv-win\versions\3.7.6and then ranScripts\mkvirtualenv, and the command gets executed normally and I can create the virtualenv. Same goes for other commands given by virtualenvwrapper.Weirdly, I have checked the shims for, say,
pip, and it's made in the same way, butpipworks fine. So I am a bit stumbled here.dedale commentedon Jul 20, 2021
I cannot reproduce:
dedale commentedon Jul 20, 2021
OK, I can reproduce when I run the command with the wrong Python activated:
Following your steps, mkvirtualenv is only available for one Python version, the one that was activated when
piprun.So this works only when you activate the right Python version.
I'll see what I can do to improve the error (should be something like command not found).
filipporemonato commentedon Jul 20, 2021
Hi dedale, note that you used

pyenv local 3.7.7instead ofpyenv shellas in the issue posted above. See screenshot below, which I just reproduced:EDIT - After dedale's second answer: It seems to me that the correct Python version is active in the screenshot above, that I verify with
pyenv shell; it might be a conflict between the global/local/shell Python versions being used, perhaps? However, bothpyenv globalandpyenv localreturn "No global (local) version configured", so the only one active in my shell is the one frompyenv shell, which seems to be the right one.kirankotari commentedon Jul 20, 2021
To Reproduce
Step 1. Is wrong. Why? find the below explanation.
pyenv shell <version>doesn't confirm correct python version. It sets the default python shell to the given version even you configure thepyenv localthe python shell (interpreter) uses the default which is configured.If you wanted to validate the python is set, use following commands
pyenv versionorpyenv versionsorpyenv version-nameTo set use following commands
pyenv local <version>orpyenv global <version>filipporemonato commentedon Jul 21, 2021
Hi Kirankotari,
No, step 1 is correct.
pyenv shell <version>sets the version of Python for the current shell. To confirm the active Python version one can then usepyenv shell,i.e. without the<version>argument, as explained in the help function. You can also see this in the screenshot I posted right above your reply. Perhaps I should have been more specific.After setting the Python version with step 1, the same version (i.e. 3.7.6) is shown as the active one by all of the commands
pyenv shell,pyenv version,pyenv version-name, andpyenv versions(marked with a star).Fix infinite loop when shim unavailable
Fix infinite loop when shim unavailable
Fix infinite loop when shim unavailable
Add failing test for pyenv-win#287