curl – Poetry – RuntimeError: No python executable found in shell environment. Tried: [‘python3’, ‘python’, ‘py.exe -3’, ‘py.exe -2’]

Goal: Get Poetry working via Git Bash.

Issue

Git Bash:

HDS+dabell@PF2DCSXD MINGW64 ~/Anaconda3
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
Retrieving Poetry metadata

This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.
# 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:

%USERPROFILE%.poetrybin

This path will then be added to your `PATH` environment variable by
modifying the `HKEY_CURRENT_USER/Environment/PATH` registry key.

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

Installing version: 1.1.13
  - Downloading poetry-1.1.13-win32.tar.gz (71.14MB)
Traceback (most recent call last):
  File "<stdin>", line 1118, in <module>
  File "<stdin>", line 1114, in main
  File "<stdin>", line 362, in run
  File "<stdin>", line 556, in install
  File "<stdin>", line 704, in make_bin
  File "<stdin>", line 693, in _which_python
RuntimeError: No python executable found in shell environment. Tried: ['python3', 'python', 'py.exe -3', 'py.exe -2']

So, I went into Anaconda3duplicated python.exerenaming it python3.exe:

HDS+dabell@PF2DCSXD MINGW64 ~/Anaconda3
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
bash: python3: command not found
curl: (23) Failure writing output to destination
(base)
HDS+dabell@PF2DCSXD MINGW64 ~/Anaconda3
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
Retrieving Poetry metadata

This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.
Latest version already installed.
(base)
HDS+dabell@PF2DCSXD MINGW64 ~
HDS+dabell@PF2DCSXD MINGW64 ~/Documents/GitHub/lumada-catalog/synthetic-data-gen (daniel_sims)
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
Retrieving Poetry metadata

This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.
Latest version already installed.
(base)
HDS+dabell@PF2DCSXD MINGW64 ~/Documents/GitHub/lumada-catalog/synthetic-data-gen (daniel_sims)
$ poetry install
bash: poetry: command not found
(base)

I then tried Powershell:

PS C:Usersdabell> (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python3       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:UsersdabellAppDataRoamingPythonScripts

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

Installing Poetry (1.1.13)
Installing Poetry (1.1.13): Creating environment
Installing Poetry (1.1.13): Installing Poetry
Installing Poetry (1.1.13): Creating script
Installing Poetry (1.1.13): Done

Poetry (1.1.13) is installed now. Great!

To get started you need Poetry's bin directory (C:UsersdabellAppDataRoamingPythonScripts) in your `PATH`
environment variable.

Alternatively, you can call Poetry explicitly with `C:UsersdabellAppDataRoamingPythonScriptspoetry`.

You can test that everything is set up by executing:

`poetry --version`

PS C:Usersdabell> poetry --version
poetry : The term 'poetry' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ poetry --version
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (poetry:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
PS C:Usersdabell> echo ($env:path)
C:Program FilesCommon FilesOracleJavajavapath;
C:Program Files (x86)Common FilesOracleJavajavapath;
C:WINDOWSsystem32;
C:WINDOWS;
C:WINDOWSSystem32Wbem;
C:WINDOWSSystem32WindowsPowerShellv1.0;
C:WINDOWSSystem32OpenSSH;
C:Program Files (x86)gsgs9.56.1bin;
C:UsersdabellAnaconda3;
C:UsersdabellAnaconda3Librarymingw-w64bin;
C:UsersdabellAnaconda3Libraryusrbin;
C:UsersdabellAnaconda3Librarybin;
C:UsersdabellAnaconda3Scripts;
C:UsersdabellAppDataLocalProgramsPythonPython310;
C:UsersdabellAppDataLocalProgramsGitcmd;
C:UsersdabellAppDataRoamingPythonScripts;

The last line I’ve successfully added.


Git Bash:

HDS+dabell@PF2DCSXD MINGW64 ~/Documents/GitHub/lumada-catalog/synthetic-data-gen (daniel_sims)
$ poetry --version
Poetry version 1.1.13
(base)

HDS+dabell@PF2DCSXD MINGW64 ~/Documents/GitHub/lumada-catalog/synthetic-data-gen (daniel_sims)
$ poetry install

  EnvCommandError

  Command C:UsersdabellAnaconda3python.exe -W ignore - errored with the following return code 1, and output:
  input was : import sys

  if hasattr(sys, "real_prefix"):
      print(sys.real_prefix)
  elif hasattr(sys, "base_prefix"):
      print(sys.base_prefix)
  else:
      print(sys.prefix)


  at ~AppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py:1195 in _run
Traceback (most recent call last):
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1180, in _run
    output = subprocess.run(
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutils_compat.py", line 217, in run
    raise CalledProcessError(
poetry.utils._compat.CalledProcessError: Command 'C:UsersdabellAnaconda3python.exe -W ignore -' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitconsole_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapicommandcommand.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapicommandcommand.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapieventevent_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapieventevent_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryconsoleconfigapplication_config.py", line 119, in set_env
    env = env_manager.create_venv(io)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 659, in create_venv
    env = self.get(reload=True)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 520, in get
    return self.get_system_env()
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 886, in get_system_env
    env = GenericEnv(base_prefix, child_env=env)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1498, in __init__
    super(GenericEnv, self).__init__(path, base=base)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1375, in __init__
    self._base = Path(self.run_python_script(GET_BASE_PREFIX).strip())
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1163, in run_python_script
    return self.run(self._executable, "-W", "ignore", "-", input_=content, **kwargs)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1152, in run
    return self._run(cmd, **kwargs)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1566, in _run
    return super(VirtualEnv, self)._run(cmd, **kwargs)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryutilsenv.py", line 1195, in _run
    raise EnvCommandError(e, input=input_)
poetry.utils.env.EnvCommandError: Command C:UsersdabellAnaconda3python.exe -W ignore - errored with the following return code 1, and output:
input was : import sys

if hasattr(sys, "real_prefix"):
    print(sys.real_prefix)
elif hasattr(sys, "base_prefix"):
    print(sys.base_prefix)
else:
    print(sys.prefix)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:UsersdabellAnaconda3librunpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:UsersdabellAnaconda3librunpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:UsersdabellAppDataRoamingPythonScriptspoetry.exe__main__.py", line 7, in <module>
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagespoetryconsole__init__.py", line 5, in main
    return Application().run()
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitconsole_application.py", line 142, in run
    trace.render(io, simple=isinstance(e, CliKitException))
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikituicomponentsexception_trace.py", line 232, in render
    return self._render_exception(io, self._exception)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikituicomponentsexception_trace.py", line 269, in _render_exception
    self._render_snippet(io, current_frame)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikituicomponentsexception_trace.py", line 289, in _render_snippet
    self._render_line(io, code_line)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikituicomponentsexception_trace.py", line 402, in _render_line
    io.write_line("{}{}".format(indent * " ", line))
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagescleoioio_mixin.py", line 65, in write_line
    super(IOMixin, self).write_line(string, flags)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapiioio.py", line 66, in write_line
    self._output.write_line(string, flags=flags)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapiiooutput.py", line 69, in write_line
    self.write(string, flags=flags, new_line=True)
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitapiiooutput.py", line 61, in write
    self._stream.write(to_str(formatted))
  File "C:UsersdabellAppDataRoamingpypoetryvenvlibsite-packagesclikitiooutput_streamstream_output_stream.py", line 24, in write
    self._stream.write(string)
  File "C:UsersdabellAnaconda3libencodingscp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character 'u2502' in position 28: character maps to <undefined>
(base)

Leave a Comment