Open hongyi-zhao opened 4 years ago
Actually, you can't create a virtualenv because pyenv-virtualenv
tries to install the latest version of virtualenv, but at the end of 2021 (before Python 2.7 EOL), the last supported version was 16.7.12.
So, for this to work, you need to specify version 16.7.12 for virtualenv. There are two ways to do this:
export VIRTUALENV_VERSION=16.7.12
pyenv virtualenv 2.7.18 your_venv-py27
The other way to do this is to patch the pyenv-virtualenv
script as follows:
@@ -385,14 +385,17 @@
unset UPGRADE
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--upgrade"
fi
fi
if [ -z "${VIRTUALENV_VERSION}" ]; then
case "${PYENV_VERSION}" in
+ "2.7"* )
+ VIRTUALENV_VERSION="16.7.12"
+ ;;
"3.0"* )
NO_ENSUREPIP=1
;;
"3.1"* )
NO_ENSUREPIP=1
;;
"3.2"* | "stackless-3.2"* )
What about create a PR of this patch?
@hongyi-zhao, Hello, I'm not a bash/fish/zsh developer, I'm a Python developer first of all and so it will be difficult for me to contribute to this project without significant effort: how should I write unit tests to check that the bug fix works well and that there is no regression?
On the other hand, I think the problem is more global: we should be able to make sure that we can install virtualenv whatever the version of Python is, including end-of-life versions (which are not supported anymore). We also need to make sure that we use a fresh version of virtualenv so that we can install recent (recent enought) versions of pip
, setuptools
and wheel
.
If we look at the end of life dates of Python versions, we can find a version of virtualenv that fits this date. For example, virtualenv v16.7.11 was released on 2021-07-20, this is the last version released before the end of life of Python 2.7.18 which was on 2020-01-01.
The table below lists the minor versions of virtualenv v20 that are considered stable:
It is easy to notice that all new versions have been released after 2020-01-28, so only for Python 3.6 (the end of life of Python 3.5 took place on 2020-09-30).
The table below lists the legacy versions of virtualenv:
@laurent-laporte-pro If so, it is not so easy to fix this problem systematically and gracefully.
Actually, you can't create a virtualenv because
pyenv-virtualenv
tries to install the latest version of virtualenv, but at the end of 2021 (before Python 2.7 EOL), the last supported version was 16.7.12.So, for this to work, you need to specify version 16.7.12 for virtualenv. There are two ways to do this:
That's strange. This should work, and pyenv virtualenv test
indeed WFM for 2.7.18 with the latest Pyenv and Pyenv-Virtualenv.
It runs pip install virtualenv
, and Pip is supposed to pick not just the latest release but the latest release supported by the Python that the running instance of Pip belongs to.
First, make sure that pip
in your environment indeed belongs to the specific Python instance (check the output of pip --version
)
If it does, please provide a debug trace of the problem:
Run PYENV_DEBUG=1 PIP_VERBOSE=3 <faulty Pyenv invocation>
and provide the resulting output as a gist.
ERROR: Could not find an activated virtualenv (required).
This error message happens when PIP_REQUIRE_VIRTUALENV
or PIP_REQUIRE_VENV
envvars are set, or the corresponding switches are passed to Pip. But pyenv-virtualenv
unsets those envvars (since a commit from 2014) and you don't supply any other command line options if your report is accurate.
So will need to see the trace to try and find out where they are coming from.
Hi,
This is Ubuntu 20.04 and git master version of pyenv/pyenv-virtualenv. Failed to do the following job:
But for python 3.x.x versions, this problem doesn't appear.
Any hints?
Regards