Closed Sukanya-rs closed 1 year ago
Tried the same in 3.8.10 version , it works fine!
mac@macs-MacBook-Pro Project % pyenv virtualenv 3.8.10 test_3
.8.10
Looking in links: /var/folders/k8/vqd8k8s96dbcg8cnv5b9gjt80000gn/T/tmp20jkbec6
Requirement already satisfied: setuptools in /Users/mac/.pyenv/versions/3.8.10/envs/test_3.8.10/lib/python3.8/site-packages (56.0.0)
Requirement already satisfied: pip in /Users/mac/.pyenv/versions/3.8.10/envs/test_3.8.10/lib/python3.8/site-packages (21.1.1)
mac@macs-MacBook-Pro Project % pyenv versions
mac@macs-MacBook-Pro Project % pyenv versions
system
3.8.10
3.8.10/envs/test_3.8.10
3.10.5
* 3.10.6 (set by PYENV_VERSION environment variable)
3.10.6/envs/pysyft_0.6.0
3.10.6/envs/pysyft_0.7.0
pysyft_0.6.0
pysyft_0.7.0
test_3.8.10
mac@macs-MacBook-Pro Project % pyenv activate test_3.8.10
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(test_3.8.10) mac@macs-MacBook-Pro Project % pyenv deactivate
mac@macs-MacBook-Pro Project %```
Tried "source deactivate" command and it worked and closing the issue.
I observed the same issue on 3.10 version of python, even "source deactivate" command did not work.
Please provide a debug trace of the faulty invocation for us to be able to say anything.
export PYENV_DEBUG=1
export PS4='+(${BASH_SOURCE:-}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -x
<reproduce the problem>
set +x
unset PYENV_DEBUG
If your shell is Zsh, replace ${BASH_SOURCE:-}
with ${BASH_SOURCE:-${(%):-%x}}
.
have the same issue on mac m1 when pyenv-virtualenv not deactivating when virtualenv set to global with pyenv
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % env | grep VIRT
PYENV_VIRTUALENV_INIT=1
PIP_REQUIRE_VIRTUALENV=true
PYENV_VIRTUALENV_DISABLE_PROMPT=1
PYENV_VIRTUAL_ENV=/Users/anatoly.lebedev/.pyenv/versions/3.11.0/envs/tools
VIRTUAL_ENV=/Users/anatoly.lebedev/.pyenv/versions/3.11.0/envs/tools
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % pyenv deactivate tools
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % env | grep VIRT
PYENV_VIRTUALENV_INIT=1
PIP_REQUIRE_VIRTUALENV=true
PYENV_VIRTUALENV_DISABLE_PROMPT=1
PYENV_VIRTUAL_ENV=/Users/anatoly.lebedev/.pyenv/versions/3.11.0/envs/tools
VIRTUAL_ENV=/Users/anatoly.lebedev/.pyenv/versions/3.11.0/envs/tools
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % pyenv --version
pyenv 2.3.7
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % pyenv virtualenv --version
pyenv-virtualenv 1.1.5 (python -m venv)
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % pyenv global
tools
3.11.0
anatoly.lebedev@anatolylebedevs-MacBook-Pro bin % pyenv versions
system
* 3.11.0 (set by /Users/anatoly.lebedev/.pyenv/version)
3.11.0/envs/tools
* tools (set by /Users/anatoly.lebedev/.pyenv/version)
Here is a gist with debug info https://gist.github.com/albdv/d431df6c0d715aa31f9793f83d8e9323
@albdv If it's set to be global(ly selected), it's not supposed to be deactivating, ever. Why would it? You deactivate it, but then Pyenv-Virtualenv sees that it's the selected version so it activates it right back. That's exactly what I see happening in your trace.
If you need something else, you need to either unset it as the global version, or override the global version with pyenv local
or pyenv shell
.
I ran into this exact issue.. What ended up working for me was running this from the directory where the virtualenv was setup:
pyenv deactivate .
Just running the command without the .
gave me:
Failed to deactivate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
Not sure why it thinks its not loaded properly, because it is afaik. 🤷♂️
I ran into this exact issue.. What ended up working for me was running this from the directory where the virtualenv was setup:
pyenv deactivate .
Just running the command without the
.
gave me:Failed to deactivate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. Please restart current shell and try again.
Not sure why it thinks its not loaded properly, because it is afaik. 🤷♂️
Check if pyenv-virtualenv is initialized: Make sure that pyenv-virtualenv is correctly initialized in your shell's configuration file (like .bashrc, .zshrc, etc.). You should find lines similar to the following in your configuration file:
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null && eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
I run into a similar issue.
But the root cause was a mistake at my side (my fault):
I wrongly have set my local python version to the virtualenv at some point (pyenv local myvenv
). So when running pyenv deactivate
, the local version (which was also set to myvenv
) was being loaded. The commands pyenv local
, pyenv versions
and cat ~/.python-version
helped me to troubleshoot.
To solve this, I just removed my virtualenv from being set as pyenv local
(rm ~/.python-version
).
TLDR: It my specific case, it was a misconfiguration from my side.
Note: If you set your global version to the venv (pyenv global myvenv
), you'll run into a similar issue as well.
Pyenv is not deactivating from virtual environment: Python 3.10.6
Description
Looked into similar issues before raising current issue. Hope to get some help!