question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

install-poetry.py fails with "no module named 'virtualenv'" when run with Python from the Microsoft Store

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Windows 10 20H2 (10.0.19042.1052)

  • Poetry version: N/A

  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

I’m trying the new installer with Pyton 3.9 from the Microsoft Store.

PS C:\> get-command python

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python.exe                                         0.0.0.0    C:\Users\sam\AppData\Local\Microsoft\WindowsApps\python.exe

PS C:\> (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

C:\Users\sam\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Scripts

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

You are installing 1.1.6. When using the current installer, this version does not support updating using the 'self update' command. Please use 1.2.0a1 or later.
Installing Poetry (1.1.6)
Installing Poetry (1.1.6): Creating environment
Traceback (most recent call last):
  File "<stdin>", line 831, in <module>
  File "<stdin>", line 827, in main
  File "<stdin>", line 440, in run
  File "<stdin>", line 462, in install
  File "<stdin>", line 526, in make_env
ModuleNotFoundError: No module named 'virtualenv'

When install-poetry.py runs pip to install the virtualenv module, it doesn’t check the return code. If I change the installer to use subprocess.check_call then I get:

Installing Poetry (1.1.6): Creating environment
An error has occured: Command '['C:\\Users\\sam\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\python.exe', '-m', 'pip', 'install', 'virtualenv', '-t', 'C:\\Users\\sam\\AppData\\Local\\Temp\\tmpsno44236']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "c:\users\sam\appdata\local\temp\install-poetry.py", line 440, in run
    self.install(version)
  File "c:\users\sam\appdata\local\temp\install-poetry.py", line 462, in install
    env_path = self.make_env(version)
  File "c:\users\sam\appdata\local\temp\install-poetry.py", line 518, in make_env
    subprocess.check_call(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:\\Users\\sam\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\python.exe', '-m', 'pip', 'install', 'virtualenv', '-t', 'C:\\Users\\sam\\AppData\\Local\\Temp\\tmpsno44236']' returned non-zero exit status 1.

… but I’ve no idea where the output of pip is disappearing to.

If I try to run pip manually, I get…

PS C:\Users\sam\AppData\Local\Temp> python -m pip install virtualenv -t vvv
ERROR: Can not combine '--user' and '--target'
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the 'C:\Users\sam\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

No idea what’s going on there. But I think the installer should have caught the error & displayed it to me.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sboomicommented, Jun 22, 2021

I have more or less the same issue with Ubuntu 20.08, when I try to execute the following:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3.8 -

I believe it’s because of that part of the installation:

        with temporary_directory() as tmp_dir:
            subprocess.call(
                [sys.executable, "-m", "pip", "install", "virtualenv", "-t", tmp_dir],
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
            )

            sys.path.insert(0, tmp_dir)

            import virtualenv

            virtualenv.cli_run([str(env_path), "--clear"])

        return env_path

The virtualenv installed lacks a special module necessary to proceed with, which is the virtualenv.seed.via_app_data one. I tried uninstalling virtualenv multiple times without any success.

1reaction
abncommented, Nov 18, 2021

The root cause of this issue was resolved by #4099. See the bottom part of https://github.com/python-poetry/poetry/issues/4463#issuecomment-972734348 for more information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModuleNotFoundError: No module named 'virtualenv' in Python
To solve the error, install the module by running the pip install virtualenv command. no module named virtualenv. Open your terminal in your ......
Read more >
ImportError: No module named virtualenv - Stack Overflow
On ubuntu, I noticed that even pip install vitualenv is successful, when I execute the command to create one, it keeps saying there's...
Read more >
Configure a Poetry environment | PyCharm Documentation
Poetry is a tool that facilitates creating a Python virtual environment based on the project dependencies. You can declare the libraries your project ......
Read more >
[Fixed] ModuleNotFoundError: No module named 'virtualenv'
Quick Fix: Python raises the ImportError: No module named 'virtualenv' when it cannot find the library virtualenv . The most frequent source of...
Read more >
Python Virtual Environments tutorial using Virtualenv and Poetry
A mini-guided Python tutorial showing how to use virtual environment and why ... For Windows: $ py -3.6 -m pip install poetry #...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found