首页 > 解决方案 > 问题运行 streamlit hello

问题描述

尝试streamlit hello在 anaconda 提示窗口中运行命令时遇到以下错误。我使用它安装了它pip install streamlit,一切正常。关于为什么这不起作用的任何想法?我的 PC 是新的并运行 Windows 10,我在编码程序方面执行的唯一安装是 Anaconda。我没有单独安装python。

错误信息:

(base) C:\Users\matte>streamlit hello
Traceback (most recent call last):
  File "c:\users\matte\anaconda3\lib\site-packages\git\__init__.py", line 83, in <module>
    refresh()
  File "c:\users\matte\anaconda3\lib\site-packages\git\__init__.py", line 73, in refresh
    if not Git.refresh(path=path):
  File "c:\users\matte\anaconda3\lib\site-packages\git\cmd.py", line 278, in refresh
    raise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\users\matte\anaconda3\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\matte\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\matte\anaconda3\Scripts\streamlit.exe\__main__.py", line 4, in <module>
  File "c:\users\matte\anaconda3\lib\site-packages\streamlit\cli.py", line 28, in <module>
    import streamlit.bootstrap as bootstrap
  File "c:\users\matte\anaconda3\lib\site-packages\streamlit\bootstrap.py", line 29, in <module>
    from streamlit.server.server import Server, server_address_is_unix_socket
  File "c:\users\matte\anaconda3\lib\site-packages\streamlit\server\server.py", line 39, in <module>
    from streamlit.report_session import ReportSession
  File "c:\users\matte\anaconda3\lib\site-packages\streamlit\report_session.py", line 26, in <module>
    from streamlit.git_util import GitRepo
  File "c:\users\matte\anaconda3\lib\site-packages\streamlit\git_util.py", line 1, in <module>
    import git  # type: ignore[import]
  File "c:\users\matte\anaconda3\lib\site-packages\git\__init__.py", line 85, in <module>
    raise ImportError('Failed to initialize: {0}'.format(exc)) from exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

标签: pythongitinstallationanacondastreamlit

解决方案


基于此错误消息,我认为您需要在计算机上安装 git 和/或正确设置 $PATH

ImportError:错误的 git 可执行文件。git 可执行文件必须以下列方式之一指定: - 包含在您的 $PATH 中 - 通过 $GIT_PYTHON_GIT_EXECUTABLE 设置


推荐阅读