Python Forum
How to update pyenv pip version so that new virtualenv will use it
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to update pyenv pip version so that new virtualenv will use it
#1
Hello - This question is directed at snippsat, but is information all forum viewers should see:

You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

my question is how to force venv to use proper pip version

Pictures are worth a thousand words:
Output:
Larz60p@linux-nnem: ~:$cd /run/media/Larz60p/Data-2TB Larz60p@linux-nnem: Data-2TB:$which python /home/Larz60p/.pyenv/shims/python Larz60p@linux-nnem: Data-2TB:$python -V Python 3.7.0 Larz60p@linux-nnem: Data-2TB:$which pip /home/Larz60p/.pyenv/shims/pip Larz60p@linux-nnem: Data-2TB:$pip -V pip 18.0 from /home/Larz60p/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pip (python 3.7) Larz60p@linux-nnem: Data-2TB:$python -m venv venv Larz60p@linux-nnem: Data-2TB:$source ./venv/bin/activate (venv) Larz60p@linux-nnem: Data-2TB:$pip install requests Collecting requests Using cached https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl Collecting chardet<3.1.0,>=3.0.2 (from requests) Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl Collecting idna<2.8,>=2.5 (from requests) Using cached https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl Collecting certifi>=2017.4.17 (from requests) Using cached https://files.pythonhosted.org/packages/16/1f/50d729c104b21c1042aa51560da6141d1cab476ba7015d92b2111c8db841/certifi-2018.8.13-py2.py3-none-any.whl Collecting urllib3<1.24,>=1.21.1 (from requests) Using cached https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl Installing collected packages: chardet, idna, certifi, urllib3, requests Successfully installed certifi-2018.8.13 chardet-3.0.4 idna-2.7 requests-2.19.1 urllib3-1.23 You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command. (venv) Larz60p@linux-nnem: Data-2TB:$ (venv) Larz60p@linux-nnem: Data-2TB:$which pip /run/media/Larz60p/Data-2TB/venv/bin/pip (venv) Larz60p@linux-nnem: Data-2TB:$ (venv) Larz60p@linux-nnem: Data-2TB:$pip -V pip 10.0.1 from /run/media/Larz60p/Data-2TB/venv/lib/python3.7/site-packages/pip (python 3.7) (venv) Larz60p@linux-nnem: Data-2TB:$pip install --upgrade pip Collecting pip Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 10.0.1 Uninstalling pip-10.0.1: Successfully uninstalled pip-10.0.1 Successfully installed pip-18.0 (venv) Larz60p@linux-nnem: Data-2TB:$pip -V pip 18.0 from /run/media/Larz60p/Data-2TB/venv/lib/python3.7/site-packages/pip (python 3.7) (venv) Larz60p@linux-nnem: Data-2TB:$
Reply
#2
Inside the venv you can also update pip:

pip install pip --upgrade
After the upgrade the venv is using the new pip version.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
In the previous example, The local venv is /run/media/Larz60p/Data-2TB/venv
and the command:
pip install --upgrade pip
while running that virtual environment updates the proper pip.

I want it to be there when I create the venv, which if I understand correctly is created from my .pyenv environment
it already has pip 18.0 installed:
Output:
Larz60p@linux-nnem: ~:$which python /home/Larz60p/.pyenv/shims/python Larz60p@linux-nnem: ~:$python -V Python 3.7.0 Larz60p@linux-nnem: ~:$which pip /home/Larz60p/.pyenv/shims/pip Larz60p@linux-nnem: ~:$pip -V pip 18.0 from /home/Larz60p/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pip (python 3.7) Larz60p@linux-nnem: ~:$
however when I create a new virtual environment (before manual upgrade) it has the wrong pip version,
and then I have to manually upgrade:

example:
Output:
Larz60p@linux-nnem: ~:$mkdir ziggy Larz60p@linux-nnem: ~:$cd ziggy Larz60p@linux-nnem: ziggy:$which python /home/Larz60p/.pyenv/shims/python Larz60p@linux-nnem: ziggy:$python -V Python 3.7.0 Larz60p@linux-nnem: ziggy:$which pip /home/Larz60p/.pyenv/shims/pip Larz60p@linux-nnem: ziggy:$pip -V pip 18.0 from /home/Larz60p/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pip (python 3.7) Larz60p@linux-nnem: ziggy:$ Larz60p@linux-nnem: ziggy:$python -m venv venv Larz60p@linux-nnem: ziggy:$source ./venv/bin/activate (venv) Larz60p@linux-nnem: ziggy:$pip -V pip 10.0.1 from /home/Larz60p/ziggy/venv/lib/python3.7/site-packages/pip (python 3.7) (venv) Larz60p@linux-nnem: ziggy:$which pip /home/Larz60p/ziggy/venv/bin/pip (venv) Larz60p@linux-nnem: ziggy:$
Reply
#4
Yes, it's the right behavior.
The system wide installation of pip is copied or symlinked to your virtual environment.
The pip install command does not install system wide, when you're in a venv.
You could upgrade the system installation of pip or make a script, which upgrades pip after installing the env.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#5
I'll just continue as I have done. It's a minor annoyance.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Master thesis research: A Python version update behavior survey AJB96 2 1,489 Sep-07-2023, 08:39 PM
Last Post: Larz60+
  Adding to python environment in pyenv virtual project Larz60+ 4 2,881 Jun-26-2022, 11:26 AM
Last Post: Larz60+
  Building Mapnik for a pyenv python. Larz60+ 0 1,796 Jul-07-2021, 11:29 PM
Last Post: Larz60+
  Add package to pyenv base interpreter Larz60+ 1 1,850 Sep-11-2020, 11:58 AM
Last Post: mlieqo
  best way to transfer databases from old version of PostgreSQL to new version Larz60+ 3 3,508 Jun-20-2018, 07:13 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020