pyenv activate <venv> does not work properly

未关闭
#329 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python, shell
领域
cli, tooling

调研方向

Start by reproducing the reported pyenv activate test380, python -V, pyenv which python, and exec "$SHELL" sequence in a fresh shell. Inspect how shell initialization and activation affect command selection; done means the activated environment consistently reports Python 3.8.0 without requiring a shell reset.

由索引模型根据 Issue 内容生成。

描述

I have just noticed recently, that the above mentioned command does not switch to a virtual environment as before.
Here how it looks like atm:

(base) art@HP:~$ python --version
Python 3.7.4
(base) art@HP:~$ python -V
Python 3.7.4
(base) art@HP:~$ pyenv versions
* system (set by /home/art/.python-version)
  3.7.5
  3.8.0
  3.8.0/envs/cuda380
  cuda380
(base) art@HP:~$ pyenv virtualenv 3.8.0 test380
Looking in links: /tmp/tmp49kcmsng
Requirement already satisfied: setuptools in /home/art/.pyenv/versions/3.8.0/envs/test380/lib/python3.8/site-packages (41.2.0)
Requirement already satisfied: pip in /home/art/.pyenv/versions/3.8.0/envs/test380/lib/python3.8/site-packages (19.2.3)
(base) art@HP:~$ pyenv activate test380
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(test380) (base) art@HP:~$ python --version
Python 3.7.4
(test380) (base) art@HP:~$ python -V
Python 3.7.4
(test380) (base) art@HP:~$

From the code above you can see that I created virtual environment called "test380" which is based on 3.8.0 version of python. But when I activate it and check the version it says 3.7.4 - i.e. global version. Same if I will try pip list for example - it will show me the packages of the global python, not the virtual active one. Interesting thing is that if I go to pycharm and add the test380 venv as an interpreter, it will be 3.8.0. I am a bit confused, whats wrong in here, any idea?

I have tried deleting the .pyenv folder and installing it again with

$ curl https://pyenv.run | bash

Now I get some additional messages when I try to display the python version, but the version it shows me is still the global one:

(base) art@HP:~$ pyenv versions
* system (set by /home/art/.python-version)
  3.8.0
  3.8.0/envs/test380
  test380
(base) art@HP:~$ pyenv activate test380
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(test380) (base) art@HP:~$ python -V
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python 3.7.4

After shell reset with '$ exec "$SHELL"" it finally shows the correct venv version, but it works only once, if I reopen the terminal, the problem with wrong version remains until I execute shell reset again. Moreover after shell reset it is not shown which venv is active in the brackets, it only shows (base).

(base) art@HP:~$ pyenv activate test380
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(test380) (base) art@HP:~$ python -V
Python 3.7.4
(test380) (base) art@HP:~$ exec "$SHELL"
(base) art@HP:~$ python -V
Python 3.8.0
(base) art@HP:~$ pyenv which python
/home/art/.pyenv/versions/test380/bin/python
(base) art@HP:~$
主要语言
Shell
星标
6.7k
派生
433
平均合并
1 天 8 小时
30 天内合并 PR
11

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pyenv/pyenv-virtualenv 的其他 Issue

查看 pyenv/pyenv-virtualenv 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。