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

Unable to create Virtual Environment with MS Store Python #5331

Closed
bradfordgp opened this issue Mar 18, 2022 · 15 comments · Fixed by #5931
Closed

Unable to create Virtual Environment with MS Store Python #5331

bradfordgp opened this issue Mar 18, 2022 · 15 comments · Fixed by #5931
Labels
area/venv Related to virtualenv management area/windows For Windows-specific issues

Comments

@bradfordgp
Copy link

OS: Windows 11
Python version: 3.10.3
Initial poetry install via Powershell command: (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -

Had some problems with initial install, so ran uninstall with no problems. However, on attempting to reinstall, got the following message:

Installing Poetry (1.1.13)
Installing Poetry (1.1.13): Creating environment
Actual environment location may have moved due to redirects, links or junctions.
  Requested location: "C:\Users\321gp\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
  Actual location:    "C:\Users\321gp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Actual environment location may have moved due to redirects, links or junctions.
  Requested location: "C:\Users\321gp\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
  Actual location:    "C:\Users\321gp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Installing Poetry (1.1.13): An error occurred. Removing partial environment.
Poetry installation failed.
See C:\Users\321gp\poetry-installer-error-2yr835li.log for error logs.

Error log contains the following:

No pyvenv.cfg file

Traceback:

  File "<stdin>", line 879, in main
  File "<stdin>", line 515, in run
  File "<stdin>", line 536, in install
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1008.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "<stdin>", line 608, in make_env
  File "<stdin>", line 594, in make_env
  File "<stdin>", line 326, in make
  File "<stdin>", line 349, in pip
  File "<stdin>", line 346, in python
  File "<stdin>", line 339, in run

Checking the links listed, C:\Users\... \Roaming\pypoetry\venv\ does not exist.

Suggestions on how to correct this?

@yodaldevoid
Copy link

I have also run into this exact same problem with Windows 10 21H2 and Python 3.10.3 installed through the Microsoft Store.

@tats-u
Copy link

tats-u commented Mar 27, 2022

(Pdb) p completed_process
CompletedProcess(args=('C:\\Users\\tatsu\\AppData\\Roaming\\pypoetry\\venv\\Scripts\\python.exe', '-m', 'pip', '--isolated', 'install', '--disable-pip-version-check', '--upgrade', 'pip'), returncode=106, stdout=b'No pyvenv.cfg file\r\n')

@ChristopherGS
Copy link

+1

@s-viour
Copy link

s-viour commented Apr 24, 2022

I was having this issue too, and found not so much a fix, but a workaround:

try setting the POETRY_HOME environment variable before running the install script to a directory you created. (i.e $env:POETRY_HOME="$env:userprofile\pypoetry") after that, run the install script again

@yodaldevoid
Copy link

I have tried @s-viour's workaround without success when trying to install into $env:APPDATA\pypoetry. It did however work when installing to $env:HOMEDRIVE$env:HOMEPATH\pypoetry which makes me think this is some sort of permissions issue.

@carlamart1
Copy link

@yodaldevoid thank you, i do have the same issue. I tried to install in the windows power shell. But still have this issue :

Installing Poetry (1.1.13)
Installing Poetry (1.1.13): Creating environment
Installing Poetry (1.1.13): An error occurred. Removing partial environment.
Poetry installation failed.
See C:\Users\Power Media\poetry-installer-error-bkoawia6.log for error logs.
PS C:\Users\Power Media>

details from logs :

No pyvenv.cfg file

Traceback:

File "", line 879, in main
File "", line 518, in run

Could you help me please ?
Thank you !

@neersighted
Copy link
Member

This looks like it's actually an issue with MS Store Python -- if anyone can reproduce this on a Python.org distribution please post it here as soon as you can. If this is only reproducible on MS Store installs, I am not going to consider it a blocker for the next beta release as it's not a regression -- we just haven't fully fixed support for these Python installs.

@uhzees
Copy link

uhzees commented Jun 13, 2022

Just tested this on both MS Store Python and the Python.org manually downloaded version. I think it is the problem of the MS Store one as the latter worked with no problems.

@neersighted
Copy link
Member

#5835 is a duplicate of this as the fundamental issue is virtual environments created using a MS Store Python breaking. It's interesting to see that the install succeeded but env use failed -- I suspect that Poetry's interpreter may be a Python.org version and the user is attempting to create the project Environment with the MS Store Python.

Regardless, this makes me think that this may be an issue in Poetry itself as well as the installer and it may need to be prioritized higher.

@neersighted neersighted changed the title uninstall / reinstall not working due to missing pyvenv.cfg Unable to create Virtual Environment with MS Store Python Jun 15, 2022
@neersighted neersighted added area/venv Related to virtualenv management area/windows For Windows-specific issues labels Jun 15, 2022
@finswimmer
Copy link
Member

Hello everybody,

I slowly made progress here. The problem with Python installed from the MS Store is, that it is an UWP app and Microsoft redirects access to some folder into a sandbox folder. And this is not always done transparent.

I've created a proof-of-concept to workaround this. The install-poetry.py script needed a fix and Poetry itself. You can find it here:

One can test it like this:

curl https://raw.githubusercontent.com/finswimmer/install.python-poetry.org/fix/ms-store/install-poetry.py | python3 - --git https://github.com/finswimmer/poetry.git@python-ms-store

Please note: It's a POC and the code is not as beautiful as it could be.

@kartik-gupta-ij
Copy link

I have also run into this exact same problem with Windows 10 21H2 and Python 3.10.3 installed through the Microsoft Store.

this was the issue fixed thanks

@ayushkamadji
Copy link

I'm still getting the same issue with the web installer with MS Store python: "Actual environment location may have moved due to redirects, links or junctions.". I think the fix is being reverted as mentioned in python-poetry/install.python-poetry.org#86.
Consider reopening.

@temeddix
Copy link

temeddix commented Aug 7, 2023

This shouldn't be closed, as this bug affects considerable amount of people who are downloading Python from Microsoft store. I tried using Poetry and this problems keep appearing. Please don't ignore this issue, devs.

@temeddix temeddix mentioned this issue Aug 8, 2023
2 tasks
@dechamps
Copy link

I am not a Poetry user, but just as an FYI, I found a similar issue in pipx that I suspect has the same root cause (i.e. Python venvs not playing well with Windows app package path redirection): pypa/pipx#1164 Maybe we can compare notes.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/venv Related to virtualenv management area/windows For Windows-specific issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.