使用pyenv安装python后找不到python3命令

lch*_*lch 5 python pip pyenv

我用pyenv安装了特定版本的python。pyenv version在终端输入时,我看到了3.5.0 (set by /Users/lcherukuri/.python-version)。但是当我打字的时候python3我得到了python3 command not found。如何解决这个问题?找不到pip3

Zor*_*one 8

如果使用 pyenv 同时安装了 python 2.x 和 python 3.x,请运行以下命令以启用全局找到这两个版本(python、python2 和 python3 别名)。

添加您正在使用的特定版本:

pyenv global 3.8.3 2.7.18
Run Code Online (Sandbox Code Playgroud)


Jus*_*hur 8

pyenvpython3管理和 等命令的 shim 可执行文件pip3。如果 pyenv 的垫片在您的 shell 中不可用,通常意味着以下两种情况之一:

  • pyenv 未完全安装

或者

  • pyenv shell 功能未激活

As your pyenv command is working but the shims aren't, it most likely means the shell features aren't activated. As of writing, the correct way is to ensure the init command output is evaluated. On macOS, you can add the following to your ~/.bash_profile:

eval "$(pyenv init -)"
Run Code Online (Sandbox Code Playgroud)

Older installation instructions might not include that step or just have you add pyenv's bin directory to the PATH, which is not enough. If you used pyenv-installer, this step is hinted at in a warning at the end of the installation process.

  • 这个答案因其所包含的概念、逻辑和上下文的数量而值得获奖。它让我省去了很多挣扎。谢谢。 (2认同)

jmk*_*may 3

pyenv只是一个Python版本管理器。python3即使未安装在您的 $PATH 中,它也可能能够看到已安装的 Python 3.X。

您需要添加python3到您的 $PATH。您可以在此处查看如何执行此操作。

默认情况下,MacOS 用于python3区分本机预安装python(Python 2.7)和任何后安装的 Python 3.X 发行版。pip和也是如此pip3

来自pyenv管理版本的文档:

找到Python安装位置

一旦 pyenv 确定您的应用程序指定了哪个版本的 Python,它就会将该命令传递给相应的 Python 安装。

每个 Python 版本都安装在 $(pyenv root)/versions 下自己的目录中。

例如,您可能安装了以下版本:

$(pyenv root)/versions/2.7.8/

$(pyenv root)/versions/3.4.2/

$(pyenvroot)/版本/pypy-2.4.0/

就 pyenv 而言,版本名称只是 $(pyenv root)/versions 中的目录。