pyenv activate <venv> does not work properly

オープン
#329 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
11

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pyenv/pyenv-virtualenv のほかの issue

pyenv/pyenv-virtualenv の issue をすべて見る

似ている issue

Shell/Bash の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。