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

  • 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.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 11
  • Comments: 26 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I have this issue as well

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 https://github.com/python-poetry/poetry/issues/4414 is somehow related.

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.

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

(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