【问题标题】:msys2 shell can't find python even though it exists即使存在,msys2 shell 也找不到 python
【发布时间】:2018-02-20 09:44:26
【问题描述】:

如果我使用 'which' 来查找 python,它会返回:

$ which -a python.exe
which: no python.exe in (C:/msys32/mingw32/bin;/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/opt/xtensa-esp32-elf/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)

但是如果我对C:/msys32/mingw32/bin python 文件执行“目录”:

$ dir C:/msys32/mingw32/bin/py*
C:/msys32/mingw32/bin/pydoc
C:/msys32/mingw32/bin/python.exe
C:/msys32/mingw32/bin/python2.7.exe
C:/msys32/mingw32/bin/python2.7-config
C:/msys32/mingw32/bin/python2.exe
C:/msys32/mingw32/bin/python2-config
C:/msys32/mingw32/bin/python2w.exe
C:/msys32/mingw32/bin/python-config
C:/msys32/mingw32/bin/python-config.sh
C:/msys32/mingw32/bin/python-config-u.sh

这是在 Windows 10 下。请问有什么想法吗?

【问题讨论】:

  • C:/msys32/mingw32/bin;/usr/local/bin 使用了错误的分隔符和错误的路径样式。应该是/c/msys32/mingw32/bin:/usr/local/bin,对吧? Cygwin / msys2 有时会使用 Windows 样式的路径,这相当令人困惑。

标签: bash windows-10 msys2


【解决方案1】:

问题是 bash shell 找不到 python 可执行文件。要解决此问题,应在 .bashrc 文件中进行更改。

以下配置应在.bashrc文件内完成。

# python and pip alias
alias python="c:/msys64/mingw64/bin/python3.8.exe"
alias pip="c:/msys64/mingw64/bin/pip3.exe"

更多详细信息可以在blogpost上找到。

【讨论】:

    【解决方案2】:

    您可能需要简单地注销并重新登录。这在更新 ENV 时是必要的

    【讨论】:

    • 恐怕没有帮助。我已经尝试重新启动 MSYS2,但无济于事。
    猜你喜欢
    • 2019-11-10
    • 2018-09-25
    • 2018-06-17
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 1970-01-01
    • 2023-01-11
    • 1970-01-01
    相关资源
    最近更新 更多