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

Poetry 1.5 fails to install dependencies #7957

Closed
ianze opened this issue May 19, 2023 · 16 comments · Fixed by #7977
Closed

Poetry 1.5 fails to install dependencies #7957

ianze opened this issue May 19, 2023 · 16 comments · Fixed by #7977
Labels
area/venv Related to virtualenv management kind/bug Something isn't working as expected

Comments

@ianze
Copy link

ianze commented May 19, 2023

  • Poetry version: 1.5
  • Python version: 3.10
  • OS version and name: Ubuntu 20.04
  • [X ] I am on the latest stable Poetry version, installed using a recommended method.
  • [ X] I have searched the issues of this repo and believe that this is not a duplicate.
  • [X ] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [ X] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

When running Poetry install with the latest version (1.5) that was just released, I am getting No such file or directory 'python'.

The exact same project etc works fine with version 1.4.2.

@ianze ianze added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 19, 2023
@dimbleby
Copy link
Contributor

obviously poetry 1.5.0 works fine for lots of us (including the pipelines). You've provided no means to reproduce what you are seeing.

This is unactionable.

@ianze
Copy link
Author

ianze commented May 19, 2023

I was able to recreate it with a very simple pyproject.toml file

[tool.poetry]
name = "test"
# this version is not used directly
# to get the latest version run git describe --tags --abbrev=0
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "~3.9"
click = "^8.0.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

The error I am seeing after adding verbose is

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.9/subprocess.py:1821 in _execute_child
      1817│                     else:
      1818│                         err_filename = orig_executable
      1819│                     if errno_num != 0:
      1820│                         err_msg = os.strerror(errno_num)
    → 1821│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1822│                 raise child_exception_type(err_msg)
      1823│
      1824│
      1825│         def _handle_exitstatus(self, sts,

The reason for this is probably due to the fact I don't have python command defined on the Docker image I am using however I do have the command python3.
I can obviously work around it and have python defined using a simlink or something similar, however this was working fine in version 1.4.2. I did not see anything about it in the release notes and not sure if this was intentional.

@dimbleby
Copy link
Contributor

so far as I know this hasn't changed, poetry has always assumed that there's a python in the environment. cf #7348 for instance

@dimbleby
Copy link
Contributor

I'd add that if you have a repro with a dockerfile, please share it. No need to keep dribbling out the clues, just show us!

@gnuletik
Copy link

gnuletik commented May 19, 2023

Same issue here with the 1.5 upgrade on a docker image based on Debian, running apt-get install -y python-is-python3 fixed the issue!

@dimbleby
Copy link
Contributor

sharing a way to reproduce this would be more useful than announcing that you are hitting it, please

@dimbleby
Copy link
Contributor

(more evidence that this is not new: #6371)

@ianze
Copy link
Author

ianze commented May 20, 2023

@dimbleby I have done more investigating. I believe this error only happens when following environment variable is set:

POETRY_VIRTUALENVS_IN_PROJECT=true

Here is a pyproject.toml file I have used:

[tool.poetry]
name = "test"
# this version is not used directly
# to get the latest version run git describe --tags --abbrev=0
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "~3.10"
click = "^8.0.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

With the following Dockerfile

FROM ubuntu

RUN apt update

RUN apt install -y python3 curl vim

ADD pyproject.toml /

ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV PATH="/root/.local/bin:${PATH}"

# installing using version 1.4.2 - this will work
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.4.2
RUN poetry install --verbose

RUN rm -rf .venv

# Remove 1.4.2 version
RUN curl -sSL https://install.python-poetry.org | python3 - --uninstall

# installing using version 1.5
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN poetry install --verbose

Please run the following command (I am running it on mac):

docker build -t python -f Dockerfile --no-cache .

What you should see that the instructions in the file which operate on Poetry version 1.4.2 passes correctly. However, when you reach the last command in the Dockerfile which uses 1.5 that should fail with the error I provided before.

Hope this helps to understand the root cause.

@dimbleby
Copy link
Contributor

thanks!

@tzing
Copy link
Contributor

tzing commented May 22, 2023

Same issue on using macOS.

  • Poetry version: 1.5.0
  • Python version: 3.11.3 / also has 3.10 in $PATH
  • OS version and name: macOS 13.3

Found downgrade to 1.4.2 makes everything works again


Note. I have python3, python3.10, python3.11 in $PATH. But there indeed is no python, which was pointing to python2.7 in earlier macOS version.

@ghilesmeddour
Copy link

I have a problem when using poetry 1.5 and python3.11 too. (Doesn't happen with poetry 1.4 or with python 3.8 env)

It seems that poetry uses python3.8 for a reason I can't understand.

$ poetry install
Updating dependencies
Resolving dependencies... (3.1s)

file could not be opened successfully
$ poetry install --verbose

  OverrideNeeded

  at ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/provider.py:691 in complete_package
      687│                     current_overrides.update({dependency_package: package_overrides})
      688│                     overrides.append(current_overrides)
      689│ 
      690│             if overrides:
    → 691│                 raise OverrideNeeded(*overrides)
      692│ 
      693│         # Modifying dependencies as needed
      694│         clean_dependencies = []
      695│         for dep in dependencies:

The following error occurred when trying to handle this error:


  ReadError

  file could not be opened successfully

  at /usr/lib/python3.8/tarfile.py:1608 in open
      1604│                 except (ReadError, CompressionError):
      1605│                     if fileobj is not None:
      1606│                         fileobj.seek(saved_pos)
      1607│                     continue
    → 1608│             raise ReadError("file could not be opened successfully")
      1609│ 
      1610│         elif ":" in mode:
      1611│             filemode, comptype = mode.split(":", 1)
      1612│             filemode = filemode or "r"

@moltob
Copy link

moltob commented May 23, 2023

Same here, would be great if the linked fix PR could be accepted and released.

@radoering radoering added area/venv Related to virtualenv management and removed status/triage This issue needs to be triaged labels May 23, 2023
@manugarri
Copy link

thanks for the quick fix @radoering ,given how a minor release instantly broke tons of production builds, it might be good to add an update to the blog post, warning users using local environments (which id wager is the majority) to not update to 1.5.0 and wait for 1.5.1.

@ghost
Copy link

ghost commented May 29, 2023

I can reproduce with Poetry 1.5.0 on MacOS 13.3.1 M1 (Apple Silicon) with official Python 3.10.11 when Poetry has this configuration:

virtualenvs.create = true
virtualenvs.in-project = true

Even when executing like so: $(which python3.10) -m poetry install.
Error reproduces if .venv is missing in the project but, does not reproduce if I use a copy of .venv from another project.

@carljeske
Copy link

carljeske commented Jun 7, 2023

I've been struggling with this issue too with virtualenvs.create = false and Ubuntu 20.04.

I believe the root of the issue is that poetry 1.5.1 installs the packages, for my setup, in the directory /usr/lib/python3.8/site-packages/. This is not a location that python looks in for imports. Interestingly, poetry itself doesn't see the installed packages and reinstalls them everytime poetry install is ran.

Using poetry 1.4.2, the packages are instead installed to /usr/local/lib/python3.8/dist-packages/ and python can successfully import them.

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 kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants