pyenv-win icon indicating copy to clipboard operation
pyenv-win copied to clipboard

bug: Python version in .python-version is not used

Open eafpres opened this issue 5 years ago • 21 comments

Describe the bug After installing pyenv and setting version the system does not use the python version in .python-version

To Reproduce launch powershell

PS C:\Users\bbate> pyenv versions
* 3.7.9 (set by C:\Users\bbate\.python-version)
  3.8.7
PS C:\Users\bbate> pyenv local
3.7.9
PS C:\Users\bbate> python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Expected behavior Python should use 3.7.9

Screenshots N/A

Desktop (please complete the following information):

  • OS: Windows 10
  • Tools used: Powershell
  • V1.0

Additional context Add any other context about the problem here.

eafpres avatar Feb 13 '21 22:02 eafpres

+1 @eafpres I've got the exatly same problem 😢

If I install pyenv with pyenv-installer on Windows 10 with WSL Ubuntu 20.04, and execute the same commands, works perfectly!!

Did you solve this?

mfdeveloper avatar Feb 25 '21 22:02 mfdeveloper

Did you solve this?

I did not solve it, but I figured out how to do it without pyenv in Windows using Powershell.

eafpres avatar Feb 25 '21 23:02 eafpres

I did not solve it, but I figured out how to do it without pyenv in Windows using Powershell.

I see :(

Thank you so much for your response @eafpres !! I will expect that any admin user help us with this.

For while, I've fixed only one Python version with .python-version file 😞

mfdeveloper avatar Feb 26 '21 12:02 mfdeveloper

@eafpres

If you don't mind, could you explain your work around for this problem using Powershell? I have this exact same problem where the python version is unchanged even after setting pyenv global and local to different python versions.

Thanks!

Jiw0on avatar Mar 18 '21 04:03 Jiw0on

@mfdeveloper hey thanks for response. @eafpres @Jiw0on check you Environment Path which I have described in the Installation here is the link

kirankotari avatar Mar 18 '21 05:03 kirankotari

Hello @kirankotari ! Thank you so much for your response.

I checked my environment variables, and everything is ok like described in pyenv-win#finish-the-installation. Thus, I have the same problem if exists a python installation in my system

mfdeveloper avatar Mar 20 '21 11:03 mfdeveloper

Hello @mfdeveloper!

Do you have another "system" (standalone) installed version of Python? Check your PATH order in 'Environment Variables': path to pyenv shims should be higher than another installed versions (via Microsoft Store or Chocolatey)

Order in PATH

And try to change System variable PATH instead of User :) Because it works like a charm on my Windows host.

hotenov avatar Mar 30 '21 06:03 hotenov

Helloo @hotenov !!

Thank you so much for this advice. I moved up the pyenv shims like you said and it works! However, I prefer uninstall the "system" Python installed by others sources (Chocolatey, downloaded from python.org...) and use only pyenv 😄

Maybe this "warning" should be on README.md or in a Wiki page like "Known issues". Or to automate this process, the pyenv-win could identify installed system versions and do that in PATH environment variable.

What do you think about it @kirankotari ?

mfdeveloper avatar Apr 02 '21 11:04 mfdeveloper

I just did the vanilla pyenv-win install from the README on Windows, and also hit this same problem. After running the command per the instructions:

[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")

I found the pyenv-win\bin and pyenv-win\shims env variables specified on a user basis, which makes sense. However, the system Python path was still winning out. I read all over the README and found no instructions on this. I had to manually add those environment variables to my system environment variables as @hotenov instructed above.

I think pyenv-win should at least have this documented somewhere in the README.

jamesbraza avatar Feb 18 '22 19:02 jamesbraza

Helloo @hotenov !!

Thank you so much for this advice. I moved up the pyenv shims like you said and it works! However, I prefer uninstall the "system" Python installed by others sources (Chocolatey, downloaded from python.org...) and use only pyenv 😄

Maybe this "warning" should be on README.md or in a Wiki page like "Known issues". Or to automate this process, the pyenv-win could identify installed system versions and do that in PATH environment variable.

What do you think about it @kirankotari ?

@hotenov thanks a lot for the image and explanation, @hotenov @mfdeveloper @jamesbraza I have started the Wiki home page, there is a option to clone it and contribute to the community, we are happy for your contributions. wiki link

kirankotari avatar Feb 18 '22 22:02 kirankotari

@kirankotari , Hi! I would like to contribute and add this wiki page (if others don't mind =). Give me a couple of days. I'll check all steps on clean installation (because it was a year ago and some bugs were fixed, including multiple versions in .python-version file).

hotenov avatar Feb 19 '22 04:02 hotenov

@kirankotari Hello again! Wiki page is ready, but I have no permissions to push into wiki Git. You need add me to collaborators people (only they can edit wiki pages). You can see final result in my repo before that.

For other subscribers, I quote my own investigation outcome from wiki page:

  1. PATH order matters
  2. System (Machine) PATH beats User PATH

and that's it 😃 Wrong setup - not a bug.

hotenov avatar Feb 20 '22 13:02 hotenov

@kirankotari Hello again! Wiki page is ready, but I have no permissions to push into wiki Git. You need add me to collaborators people (only they can edit wiki pages). You can see final result in my repo before that.

For other subscribers, I quote my own investigation outcome from wiki page:

  1. PATH order matters
  2. System (Machine) PATH beats User PATH

and that's it 😃 Wrong setup - not a bug.

@hotenov I liked it, can you please follow the pyenv wiki format. Link, we are trying to keep aligned to it.

kirankotari avatar Feb 22 '22 05:02 kirankotari

@hotenov I liked it, can you please follow the pyenv wiki format. Link, we are trying to keep aligned to it.

@kirankotari I'll try :)

hotenov avatar Feb 22 '22 05:02 hotenov

@kirankotari DONE. I've updated page coping pyenv format.

But I still can't edit (push) into pyenv-win wiki repository. I've accepted your invitation, but have NO* permission. Even on Web UI, Edit button is not available for me. See screenshot.

hotenov avatar Feb 22 '22 07:02 hotenov

@hotenov I am not sure why it's doesn't give an option to push the wiki change request. Let me check and get back, in between if you found any links for the setup (repo settings), I can go through them to make it possible.

kirankotari avatar Feb 22 '22 19:02 kirankotari

@hotenov I am not sure why it's doesn't give an option to push the wiki change request. Let me check and get back, in between if you found any links for the setup (repo settings), I can go through them to make it possible.

@kirankotari Unfortunately, quick search didn't give any useful links and I have no such experience too. I see two ways which could help us:

  1. Try to manage permissions for certain user (me) on repo Settings -> Collaborators -> Manage Access screenshot. Maybe you should look at organization settings as well
  2. Temporary workaround: You open Wiki editing for all users. Settings -> General -> Features - Wikis - (Uncheck "Restrict editing to collaborates only"). screenshot I quickly push the page and you turn it ON again (if you afraid spam actions from bots / mad people). Very inconvenient way for future Wiki updates (collaborations) but it must work.

UPD: Later search gave me this link:

https://github.community/t/repo-wiki-contributors/633

Where GitHub staff user advice to open Wiki for all too or make docs in the repo (not in Wiki). And link from post with very cumbersome solution by 2016

hotenov avatar Feb 23 '22 04:02 hotenov

Curious...is it possible when installing a new version, that the current environment may have a "stale" environment with a previous configuration in memory and the new one not loaded into memory yet?

Maybe pyenv exec or activate a given version?

ebresie avatar Mar 06 '22 17:03 ebresie

Curious...is it possible when installing a new version, that the current environment may have a "stale" environment with a previous configuration in memory and the new one not loaded into memory yet?

Maybe pyenv exec or activate a given version?

We don't have activate options, currently we are supporting pyenv local <python-version> and you can using pipenv on top of pyenv

kirankotari avatar May 30 '22 06:05 kirankotari

@hotenov Sorry for the delay, I have sent an invite to pyenv org, please accept that might give you access to wiki page updates.

  • [ ] Keeping this thread open for wiki pages by @hotenov

kirankotari avatar May 30 '22 06:05 kirankotari

@hotenov Sorry for the delay, I have sent an invite to pyenv org, please accept that might give you access to wiki page updates.

  • [ ] Keeping this thread open for wiki pages by @hotenov

@kirankotari Yes, indeed. I have pushed my changes to wiki . Take a look :)

hotenov avatar May 30 '22 06:05 hotenov