poetry: Installing packages in a python 3.6 environment fail due to PEP 517

  • 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: Ubuntu 22.0.1

  • Poetry version: 1.2.0

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

Issue

A dependency uses MarkupSafe and our project must support python ^3.6.2. Since I updated to poetry 1.2.0, I can not use the python 3.6 environment anymore.

Installing MarkupSafe manually works, when I disable pep 517:

> poetry run python -m pip install --no-use-pep517 markupSafe==2.0.1

However, there is no option to disable pep 517 in poetry. Is there any other way to install such packages?

Errors

> poetry env use 3.6
> poetry -vvv install
Using virtualenv: /tmp/foo/.venv
Project environment contains an empty path in sys_path, ignoring.
Installing dependencies from lock file

Finding the necessary packages for the current system

Package operations: 1 install, 0 updates, 0 removals

  • Installing markupsafe (2.0.1): Pending...
Creating new session for pypi.org
  • Installing markupsafe (2.0.1): Installing...
  • Installing markupsafe (2.0.1): Failed

  Stack trace:

  2  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1469 in _run
      1467│                 )
      1468│             else:
    → 1469│                 output = subprocess.check_output(
      1470│                     command, stderr=subprocess.STDOUT, env=env, **kwargs
      1471│                 )

  1  /usr/lib/python3.10/subprocess.py:420 in check_output
       418│         kwargs['input'] = empty
       419│ 
    →  420│     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
       421│                **kwargs).stdout
       422│ 

  CalledProcessError

  Command '['/tmp/foo/.venv/bin/python', '/home/john/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.3.1-py3-none-any.whl/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/tmp/foo/.venv', '--no-deps', '/home/local/.cache/pypoetry/artifacts/09/a9/a6/7e309619221c03e9a693897779a3fa9b06b4c71edb005b6919654585d3/MarkupSafe-2.0.1.tar.gz']' returned non-zero exit status 1.

  at /usr/lib/python3.10/subprocess.py:524 in run
       520│             # We don't call process.wait() as .__exit__ does that for us.
       521│             raise
       522│         retcode = process.poll()
       523│         if check and retcode:
    →  524│             raise CalledProcessError(retcode, process.args,
       525│                                      output=stdout, stderr=stderr)
       526│     return CompletedProcess(process.args, retcode, stdout, stderr)
       527│ 
       528│ 

The following error occurred when trying to handle this error:


  Stack trace:

  3  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/pip.py:49 in pip_install
       47│ 
       48│     try:
    →  49│         return environment.run_pip(*args)
       50│     except EnvCommandError as e:
       51│         raise PoetryException(f"Failed to install {path.as_posix()}") from e

  2  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1433 in run_pip
      1431│         cmd = pip + list(args)
      1432│ 
    → 1433│         return self._run(cmd, **kwargs)
      1434│ 
      1435│     def run_python_script(self, content: str, **kwargs: Any) -> int | str:

  1  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1722 in _run
      1720│     def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
      1721│         kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
    → 1722│         return super()._run(cmd, **kwargs)
      1723│ 
      1724│     def get_temp_environ(

  EnvCommandError

  Command ['/tmp/foo/.venv/bin/python', '/home/local/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.3.1-py3-none-any.whl/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/tmp/foo/.venv', '--no-deps', '/home/local/.cache/pypoetry/artifacts/09/a9/a6/7e309619221c03e9a693897779a3fa9b06b4c71edb005b6919654585d3/MarkupSafe-2.0.1.tar.gz'] errored with the following return code 1, and output: 
  Looking in indexes: https://pypi.org/simple, 
  Processing /home/local/.cache/pypoetry/artifacts/09/a9/a6/7e309619221c03e9a693897779a3fa9b06b4c71edb005b6919654585d3/MarkupSafe-2.0.1.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /tmp/foo/.venv/bin/python /home/local/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.3.1-py3-none-any.whl/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpkvyouqoq
         cwd: /tmp/pip-req-build-80e95xhl
    Complete output (1 lines):
    /tmp/foo/.venv/bin/python: can't find '__main__' module in '/home/local/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.3.1-py3-none-any.whl/pip/_vendor/pep517/in_process/_in_process.py'
    ----------------------------------------
  WARNING: Discarding file:///home/local/.cache/pypoetry/artifacts/09/a9/a6/7e309619221c03e9a693897779a3fa9b06b4c71edb005b6919654585d3/MarkupSafe-2.0.1.tar.gz. Command errored out with exit status 1: /tmp/foo/.venv/bin/python /home/local/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.3.1-py3-none-any.whl/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpkvyouqoq Check the logs for full command output.
  ERROR: Command errored out with exit status 1: /tmp/foo/.venv/bin/python /home/local/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.3.1-py3-none-any.whl/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmpkvyouqoq Check the logs for full command output.
  

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1473 in _run
      1469│                 output = subprocess.check_output(
      1470│                     command, stderr=subprocess.STDOUT, env=env, **kwargs
      1471│                 )
      1472│         except CalledProcessError as e:
    → 1473│             raise EnvCommandError(e, input=input_)
      1474│ 
      1475│         return decode(output)
      1476│ 
      1477│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

The following error occurred when trying to handle this error:


  Stack trace:

  5  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:250 in _execute_operation
      248│ 
      249│             try:
    → 250│                 result = self._do_execute_operation(operation)
      251│             except EnvCommandError as e:
      252│                 if e.e.returncode == -2:

  4  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:323 in _do_execute_operation
      321│             return 0
      322│ 
    → 323│         result: int = getattr(self, f"_execute_{method}")(operation)
      324│ 
      325│         if result != 0:

  3  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:443 in _execute_install
      441│ 
      442│     def _execute_install(self, operation: Install | Update) -> int:
    → 443│         status_code = self._install(operation)
      444│ 
      445│         self._save_url_reference(operation)

  2  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:485 in _install
      483│         )
      484│         self._write(operation, message)
    → 485│         return self.pip_install(archive, upgrade=operation.job_type == "update")
      486│ 
      487│     def _update(self, operation: Install | Update) -> int:

  1  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:120 in pip_install
      118│     ) -> int:
      119│         try:
    → 120│             pip_install(req, self._env, upgrade=upgrade, editable=editable)
      121│         except EnvCommandError as e:
      122│             output = decode(e.e.output)

  PoetryException

  Failed to install /home/local/.cache/pypoetry/artifacts/09/a9/a6/7e309619221c03e9a693897779a3fa9b06b4c71edb005b6919654585d3/MarkupSafe-2.0.1.tar.gz

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/pip.py:51 in pip_install
       47│ 
       48│     try:
       49│         return environment.run_pip(*args)
       50│     except EnvCommandError as e:
    →  51│         raise PoetryException(f"Failed to install {path.as_posix()}") from e
       52│ 

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

More debugging has been done – this is a consequence of Poetry attempting to use its own embedded pip (or rather the pip embedded in the virtualenv module) with an interpreter that that version of pip does not support. We are discussing strategies to resolve this both short-term in 1.2 and longer term now.

No luck with either /root/.local/share/pypoetry/venv/bin/pip install --upgrade --force-reinstall pip or poetry self add pip@latest - hitting the same error as above.

It is not entirely the same error message. In #6288 it is a [Errno 2] No such file or directory, while we get `can’t find ‘main’ module in ….