pyenv / pyenv-virtualenv

a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatic virtualenv activation buggy with .python-version

patata3000 opened this issue · comments

Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.

Prerequisite

  • Make sure your problem is not listed in the common build problems.
  • Make sure no duplicated issue has already been reported in the pyenv-virtualenv issues. You should look in closed issues, too.
  • Make sure you are not asking us to help solving your specific issue.
    • GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.
  • Make sure your problem is not derived from packaging (e.g. Homebrew).
    • Please refer to the package documentation for the installation issues, etc.
  • [?] Make sure your problem is not derived from other plugins.
    • This repository is maintaining the pyenv-virtualenv plugin only. Please refrain from reporting issues of other plugins here.

Description

  • Platform information (e.g. Ubuntu Linux 20.04): archlinux 5.19.6
  • OS architecture (e.g. amd64): xf86_64
  • pyenv version: 2.3.4
  • pyenv-virtualenv version: pyenv-virtualenv 1.1.5 (python3.10 -m venv)
  • Python version: 3.10.6
  • Shell: zsh 5.9 (x86_64-pc-linux-gnu)
  • virtualenv version (if installed): Nope
  • Please attach the debug log of a faulty Pyenv invocation as a gist

Hey! So I'm trying to setup pyenv with pyenv-virtualenv. I have a virtualenv called
foo and a directory called foo_project containing a .python-version with foo
written inside. I think that I have setup pyenv and pyenv-virtualenv correctly.

In my .zshrc (and my .zprofile as well), I have:

export PYENV_ROOT="$XDG_DATA_HOME/pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1

When I cd into foo_project, it should activate foo => It does not happen.
If I run pyenv activate foo => foo gets activated.
If after that, I run pyenv deactivate => foo gets deactivated normally.
If after deactivating, I am (or I cd later on) in foo_directory => foo is (or gets) activated.

After that, pyenv-virtualenv works normally. If I cd into another directory with any
valid .python-version, virtualenv get activated.

Tell me if you need anymore info. Debug logs were hard to get. There were many, many lines...

Hey! It's working now somehow. Not sure why... Closing