找不到Python可执行文件"python",可以设置PYTHON环境变量

Can't find Python executable "python", you can set the PYTHON env variable

我用的是 m1 macbook

在 zsh 终端上, 我命令 python3 --版本 然后它显示版本 但是 python --version

zsh: command not found: python

可能是什么问题?

我试过 pyenv 然后安装, 但它会导致不同的错误

pedrojung@pedroui-MacBookPro newtemp % pyenv install 2.7.5                          
Downloading openssl-1.0.2k.tar.gz...
-> https://pyenv.github.io/pythons/6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
Installing openssl-1.0.2k...

BUILD FAILED (OS X 12.3 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/j_/1jx3n6k9085b2zsqpw92n84c0000gn/T/python-build.20220322161549.77349
Results logged to /var/folders/j_/1jx3n6k9085b2zsqpw92n84c0000gn/T/python-build.20220322161549.77349.log

Last 10 log lines:
      _dgram_write in libcrypto.a(bss_dgram.o)
      _RAND_query_egd_bytes in libcrypto.a(rand_egd.o)
      ...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [link_a.darwin] Error 1
make[3]: *** [do_darwin-shared] Error 2
make[2]: *** [libcrypto.1.0.0.dylib] Error 2
make[1]: *** [shared] Error 2
make: *** [build_crypto] Error 1

关于缺少python命令:

  • python - 调用 Python 2
  • python3 - 调用 Python 3

如果您想使用 python 命令调用 Python 3,您可以创建一个符号 link。 警告:只有 运行 如果你真的需要这个命令!

命令:sudo ln -s /usr/bin/python3 /usr/bin/python


关于 pyenv 错误:ld: symbol(s) not found for architecture i386 - 这意味着安装程序在 Intel x86 架构下可用,并且您有 Apple M1架构。