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

Ubuntu 20.04 without python-as-python3 apt package errors No such file or directory: 'python' #4416

Closed
3 tasks done
christopherpickering opened this issue Aug 20, 2021 · 26 comments
Labels
kind/bug Something isn't working as expected

Comments

@christopherpickering
Copy link

  • 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 20.04
  • Poetry version: 1.1.8

Issue

Attempting to run any poetry commands results in

Installing dependencies

  FileNotFoundError

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

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700│                     else:
      1701│                         err_filename = orig_executable
      1702│                     if errno_num != 0:
      1703│                         err_msg = os.strerror(errno_num)
    → 1704│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705│                 raise child_exception_type(err_msg)
      1706│ 
      1707│ 
      1708│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

  FileNotFoundError

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

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700│                     else:
      1701│                         err_filename = orig_executable
      1702│                     if errno_num != 0:
      1703│                         err_msg = os.strerror(errno_num)
    → 1704│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705│                 raise child_exception_type(err_msg)
      1706│ 
      1707│ 
      1708│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

  FileNotFoundError

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

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700│                     else:
      1701│                         err_filename = orig_executable
      1702│                     if errno_num != 0:
      1703│                         err_msg = os.strerror(errno_num)
    → 1704│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705│                 raise child_exception_type(err_msg)
      1706│ 
      1707│ 
      1708│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
Env Info:

  FileNotFoundError

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

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700│                     else:
      1701│                         err_filename = orig_executable
      1702│                     if errno_num != 0:
      1703│                         err_msg = os.strerror(errno_num)
    → 1704│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705│                 raise child_exception_type(err_msg)
      1706│ 
      1707│ 
      1708│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

In ubuntu 20.04 there is not "python" command, only "python3". If I install sudo apt-get install python-is-python3, then poetry starts to work again.

It would be nice if poetry picked python3 if there is no python instead of failing. There is a python installed.

@christopherpickering christopherpickering added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 20, 2021
@finswimmer
Copy link
Member

Hello @christopherpickering,

how did you install poetry?

fin swimmer

@christopherpickering
Copy link
Author

Hi @finswimmer, heres how:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(which python3) -

It installs fine.

@finswimmer
Copy link
Member

Thanks for your response! I'm able to reproduce it. It seems to be due to a change in poetry 1.1.8. I have no problems with 1.1.7. I guess #4414 is somehow related.

@luisacabs-out
Copy link

I have this issue as well

@SumGR
Copy link

SumGR commented Aug 23, 2021

I can confirm this too in Alpine 3.13.5. I didn't lock poetry to a specific version in our build pipeline and started seeing the following error:

+ poetry install

  FileNotFoundError

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

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700│                     else:
      1701│                         err_filename = orig_executable
      1702│                     if errno_num != 0:
      1703│                         err_msg = os.strerror(errno_num)
    → 1704│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705│                 raise child_exception_type(err_msg)
      1706│ 
      1707│ 
      1708│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

Poetry is installed into the Alpine image using pip3. Pinning it using pip3 install poetry==1.1.7 resolved the issue. Alpine (as well as the Ubuntu version listed above) do not create a symbolic link from python->python3.x and it seems 1.1.8 somehow introduced spawning the interpreter by that name in a subprocess call.

@wouterdb
Copy link

Same problem on Centos 8 since the release of 1.1.8

@EthanC
Copy link

EthanC commented Aug 24, 2021

Same issue on DietPi v7.5 (Debian Bullseye), adding an alias for python to python3 does not resolve either.

@jd-solanki
Copy link

Same issue on my Linux mint 20

@nicolashainaux
Copy link

The same problem shows up in older Ubuntu 18.04 (bionic), but there's no python-is-python3 package as workaround on bionic. Also things like alias python="python3.6" do not fix the issue.

@lorenzznerol
Copy link

I think I have the same on an Alpine docker container with Python 3.6 and Poetry 1.1.8 installed:

$ poetry add pandas

  FileNotFoundError

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

  at /usr/lib/python3.6/subprocess.py:1364 in _execute_child
      1360│                     if errno_num != 0:
      1361│                         err_msg = os.strerror(errno_num)
      1362│                         if errno_num == errno.ENOENT:
      1363│                             err_msg += ': ' + repr(err_filename)
    → 1364│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1365│                 raise child_exception_type(err_msg)
      1366│
      1367│
      1368│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

Installing Poetry 1.1.7 instead leads to:

$ poetry add pandas
Creating virtualenv pandas-il7asoJj-py3.6 in /root/.cache/pypoetry/virtualenvs
Using version ^1.3.2 for pandas

Updating dependencies
Resolving dependencies... (0.0s)

  AssertionError



  at /usr/lib/python3.6/site-packages/poetry/mixology/incompatibility.py:111 in __str__
      107│         )
      108│
      109│     def __str__(self):
      110│         if isinstance(self._cause, DependencyCause):
    → 111│             assert len(self._terms) == 2
      112│
      113│             depender = self._terms[0]
      114│             dependee = self._terms[1]
      115│             assert depender.is_positive()

Not knowing what the latter is about, but the python error has obviously gone when using Poetry 1.1.7 instead of Poetry 1.1.8.

yshym added a commit to yshym/watch-with-friends that referenced this issue Aug 30, 2021
yshym added a commit to yshym/watch-with-friends that referenced this issue Aug 30, 2021
@regunakyle
Copy link

Might be a little bit irrelevant but I want to ask,
is there any way to change the Python version used by Poetry in Linux (particularly Ubuntu)?

I wrote some scripts using Python 3.9 and pyproject.toml list it as a dependency.
In Linux, I can download the unofficial version of Python 3.9 from ppa:deadsnakes/ppa. (Default Python 3 is 3.8)
However, I have no idea how to set Poetry to use it.

@finswimmer
Copy link
Member

@regunakyle: poetry env use /path/to/python is what you are looking for: https://python-poetry.org/docs/master/managing-environments/#switching-between-environments

@tomaski
Copy link

tomaski commented Sep 10, 2021

Windows 10 with Ubuntu 20.04 WSL - same issue.
With version 1.1.8 every poetry command fails with /usr/bin/env: ‘python\r’: No such file or directory

Installing older version solves this for me.

# wget https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py
# python3 install-poetry.py --version 1.1.7

@pkfkmkz
Copy link

pkfkmkz commented Sep 12, 2021

I have the same problem with poetry 1.1.8 in my Zorin 16 (ubuntu 20.04 and python 3.8). I Installed poetry using:

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

I can run "poetry --version", "poetry check", "poetry init", but "poetry shell" and "poetry debug" are pretty much useless. The error i get is:

$ poetry debug

Poetry
Version: 1.1.8
Python:  3.8.10

  FileNotFoundError

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

I have not found any working fixes yet.

@yrro
Copy link

yrro commented Sep 17, 2021

I'm seeing this on Debian (unstable) too.

I installed Poetry with:

$ mkdir /tmp/poetry-venv
$ python3 -m venv /tmp/poetry-venv
$ /tmp/poetry-venv/bin/python3 -m pip install wheel
$ /tmp/poetry-venv/bin/python3 -m pip install poetry

Thing is, while /usr/bin/python does not exist, /tmp/poetry-venv/bin/python does exist (as a symlink to python3 in the same directory).

If I explicitly put the venv into the PATH, then poetry works fine (i.e., invoke it as PATH=/tmp/poetry-venv/bin:$PATH python3 -m poetry). So it looks to me like Poetry is trying to shell out to python, which will fail if either:

  • python is not in the PATH
  • the Python interpreter that launched Poetry is not called python.

I think Poetry should instead use sys.executable which will work in either of the above cases:

$ /tmp/poetry-venv/bin/python3 -c 'import sys; print(sys.executable)'
/tmp/poetry-venv/bin/python3

@finswimmer
Copy link
Member

Should be fixed via #4507

@christopherpickering
Copy link
Author

Thanks!

yshym added a commit to yshym/watch-with-friends that referenced this issue Sep 21, 2021
@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
@ooliver1
Copy link

ooliver1 commented Apr 9, 2022

(WSL) i seem to still get this issue after installing today via

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

reinstalling python3.9 does not seem to resolve

/usr/bin/env: ‘python\r’: No such file or directory

reinstalling poetry receives

bash: /usr/bin/python: No such file or directory

as i uninstalled python-is-python3, aliases and that would have removed the alternatives aliases

edit:

this was fixed via https://lifesaver.codes/answer/include-installation-instructions-for-python3-721

where this is suggested:

One of:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
# or
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

however

poetry run still fails

edit again

source $HOME/.poetry/env python3

solves this, leaving this here for others as this was google top result for me

@Sispheor
Copy link

Still present on Ubuntu 22.04

poetry --version
Poetry version 1.1.13
poetry debug

Poetry
Version: 1.1.13
Python:  3.10.4

  FileNotFoundError

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

  at /usr/lib/python3.10/subprocess.py:1842 in _execute_child
      1838│                     else:
      1839│                         err_filename = orig_executable
      1840│                     if errno_num != 0:
      1841│                         err_msg = os.strerror(errno_num)
    → 1842│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1843│                 raise child_exception_type(err_msg)
      1844│ 
      1845│ 
      1846│         def _handle_exitstatus(self, sts,

@matheushent
Copy link

I still face it. Shouldn't be closed!

@raianul
Copy link

raianul commented Jun 29, 2022


Python 2.7 will no longer be supported in the next feature release of Poetry (1.2).
You should consider updating your Python version to a supported one.

Note that you will still be able to manage Python 2.7 projects by using the env command.
See https://python-poetry.org/docs/managing-environments/ for more information.


Poetry
Version: 1.1.13
Python:  2.7.16

OSError

[Errno 8] Exec format error

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/local/lib/python2.7/dist-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python2.7/dist-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/local/lib/python2.7/dist-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/local/lib/python2.7/dist-packages/poetry/console/commands/debug/info.py", line 31, in handle
    return command.run(args, self._io)
  File "/usr/local/lib/python2.7/dist-packages/clikit/api/command/command.py", line 116, in run
    return self.handle(self.parse(args), io)
  File "/usr/local/lib/python2.7/dist-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python2.7/dist-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/local/lib/python2.7/dist-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/local/lib/python2.7/dist-packages/poetry/console/commands/env/info.py", line 16, in handle
    env = EnvManager(self.poetry).get()
  File "/usr/local/lib/python2.7/dist-packages/poetry/utils/env.py", line 502, in get
    return VirtualEnv(venv)
  File "/usr/local/lib/python2.7/dist-packages/poetry/utils/env.py", line 1375, in __init__
    self._base = Path(self.run_python_script(GET_BASE_PREFIX).strip())
  File "/usr/local/lib/python2.7/dist-packages/poetry/utils/env.py", line 1163, in run_python_script
    return self.run(self._executable, '-W', 'ignore', '-', input_=content, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/poetry/utils/env.py", line 1152, in run
    return self._run(cmd, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/poetry/utils/env.py", line 1453, in _run
    return super(VirtualEnv, self)._run(cmd, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/poetry/utils/env.py", line 1186, in _run
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 409, in run
    process = Popen(*popenargs, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 617, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 1415, in _execute_child
    raise child_exception_type(errno_num, err_msg)```

Hi any update? how to fix this? 

@lifr0m
Copy link

lifr0m commented Jul 1, 2022

Just remove virtual environment directory. If you enabled virtualenvs.in-project you need to remove '.venv' in your project directory.

@dreamcoin1998
Copy link

(WSL) i seem to still get this issue after installing today via

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

reinstalling python3.9 does not seem to resolve

/usr/bin/env: ‘python\r’: No such file or directory

reinstalling poetry receives

bash: /usr/bin/python: No such file or directory

as i uninstalled python-is-python3, aliases and that would have removed the alternatives aliases

edit:

this was fixed via https://lifesaver.codes/answer/include-installation-instructions-for-python3-721

where this is suggested:

One of:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
# or
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

however

poetry run still fails

edit again

source $HOME/.poetry/env python3

solves this, leaving this here for others as this was google top result for me

If you run on wsl, sometimes it may be caused by the difference line endings between windows and linux.
Its CRLF(\r\n) in windows,and LF(\n) in linux. The line endings of the poetry maybe CRLF and run on wsl or linux.
You can try:

sudo apt install dos2unix
which poetry | xargs -I {} dos2unix {}

then try poetry agant.
Its ok with me.
It's a terrible experience to develop in WSL.

@christopherpickering
Copy link
Author

@dreamcoin1998 did you try using

apt-get install python3
curl -sSL https://install.python-poetry.org | python3 -

https://python-poetry.org/docs/master/

Wonder if that will fix it?

On the website docs somehow the default view is not the latest docs, you have to change to "master" in the top.

@websmyths
Copy link

got this error on a MacBook using Anaconda. I solved it by installing toml first with conda:

conda install toml

After that poetry install worked with no error.

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

No branches or pull requests