python指向我系统的默认 python 解释器,而不是我的pyenvpython 解释器。
我创建了python虚拟环境并激活它如下:
pyenv virtualenv 3.8.12 test3
pyenv activate test3
然后,运行python给了我一个 python 3.7 解释器(这是我系统的默认 python 解释器),而不是 3.8.12。为什么?
完整的命令输出:
root@server:/home/code-base/f# pyenv virtualenv 3.8.12 test3
Looking in links: /tmp/tmp1yp95sav
Requirement already satisfied: setuptools in /root/.pyenv/versions/3.8.12/envs/test3/lib/python3.8/site-packages (56.0.0)
Requirement already satisfied: pip in /root/.pyenv/versions/3.8.12/envs/test3/lib/python3.8/site-packages (21.1.1)
root@server:/home/code-base/f# pyenv activate test3
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(test3) root@server:/home/code-base/f# python
Python 3.7.11 (default, Jul 27 2021, 14:32:16)
[GCC 7.5.0] :: Anaconda, Inc. on linux
此外:
pyenv which python返回/root/.pyenv/versions/test3/bin/pythoncommand -v python返回/opt/conda/bin/python$PATH在我的虚拟环境中:/root/.pyenv/plugins/pyenv-virtualenv/shims:/root/.pyenv/bin:/opt/conda/bin:/app/python/bin:/opt/conda/bin:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/binls -la /root/.pyenv/plugins/pyenv-virtualenv/shims包含两个文件夹:activate和deactivate.