This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: How to update pip permanently for new venv?
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: ensurepip --upgrade doesn't change the version of pip used by venv
View: 37107
Assigned To: Nosy List: ned.deily, tillus, vinay.sajip
Priority: normal Keywords:

Created on 2020-06-10 12:26 by tillus, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg371187 - (view) Author: tillus (tillus) Date: 2020-06-10 12:26
**Describe the bug**
Every new environment has the old pip version (19.2.3)

**Expected behavior**
My system python has pip version 20 so I would expect direnv also to use the most recent pip version. But it installs the old pip version for every new environment

**Environment**
 - OS: macOS Catalina 10.15.4
 - Shell: zsh 5.7.1
 - Python version: stable 3.7.7 (homebrew bottled)

**To Reproduce**
  ```console
➜  ~ pip list
Package            Version
------------------ -------
appdirs            1.4.4
astroid            2.4.1
distlib            0.3.0
filelock           3.0.12
importlib-metadata 1.6.1
isort              4.3.21
lazy-object-proxy  1.4.3
mccabe             0.6.1
numpy              1.18.5
pip                20.1.1
pylint             2.5.2
python-dateutil    2.8.1
pytz               2020.1
setuptools         40.8.0
six                1.12.0
toml               0.10.1
typed-ast          1.4.1
virtualenv         20.0.21
wheel              0.33.1
wrapt              1.12.1
zipp               3.1.0
➜  ~ python3 -m venv ./foobar
➜  ~ source ./foobar/bin/activate
(foobar) ➜  ~ pip list
Package    Version
---------- -------
pip        19.2.3 
setuptools 41.2.0 
WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
```
msg371312 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-06-11 17:11
Thanks for the report.  I have to agree that the behavior is a little bit counterintuitive but I believe everything is working as designed and documented.  It all comes down to the fact that the ensurepip module is only concerned with the version of pip bundled with the python release; ensurepip deliberately does not check PyPI for a newer version of pip.  As documented, venv calls ensurepip after creating a new venv so the pip that is installed there is the one released with ensurepip. To get the latest version of pip, you would need to run (in the activated venv):

python3 -m pip install --upgrade pip

just as you needed to do to upgrade the system-wide instance of python3 to the latest pip.

https://docs.python.org/3/library/venv.html#creating-virtual-environments
  "Unless the --without-pip option is given, ensurepip will be invoked
   to bootstrap pip into the virtual environment."

https://docs.python.org/3/library/venv.html#creating-virtual-environments
  "Note: This module does not access the internet [...]"
msg371314 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-06-11 17:21
Also, this issue has come up before and is discussed in more detail in Issue37107, so let's continue any further discussion there.
msg371331 - (view) Author: tillus (tillus) Date: 2020-06-12 05:20
If it is not a bug, then I would strongly suggest it as a feature request!

Allright we can track it on the other issue! Thank you.
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85112
2020-06-12 05:20:42tillussetmessages: + msg371331
2020-06-11 17:21:05ned.deilysetstatus: open -> closed
superseder: ensurepip --upgrade doesn't change the version of pip used by venv
messages: + msg371314

resolution: duplicate
stage: resolved
2020-06-11 17:11:03ned.deilysetnosy: + ned.deily
messages: + msg371312
2020-06-10 15:31:07zach.waresetnosy: + vinay.sajip, - asvetlov, yselivanov
components: + Library (Lib), - asyncio
2020-06-10 12:26:43tilluscreate