Python Forum
Python venv and PIP version issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python venv and PIP version issue
#1
My work computer runs windows and I do not have admin rights. The computer however does allow install of Python using the company's package manager. The package manager installs python into c:\program files and updates the path. It also installs PIP into c:\program files.

If I update PIP using pip install --upgrade pip, the new version of pip is installed into my local appdata directory. According to documentation, this appears to be normal because on windows, pip installs packages to the appdata by default. I did however I did notice that I had to update the path variable to favor the appdata directory first or the older global verison of pip gets run instead.

When I create a new virtual environment using python -m venv <myproject>\.venv, the older version of pip in program files is copied over to the virtual environment instead of the newer version in appdata. This is despite that the older PIP is later in the path. Is this some sort of bug or is there a way around this?

My current workaround is to run pip again in the virtual environment, which seems to install the pip into the virtual environment.
Reply
#2
(Feb-21-2023, 08:06 PM)JanOlvegg Wrote: When I create a new virtual environment using python -m venv <myproject>\.venv, the older version of pip in program files is copied over to the virtual environment instead of the newer version in appdata. This is despite that the older PIP is later in the path. Is this some sort of bug or is there a way around this?
This is noraml and i don't know if there is a fix.
# Before
λ pip -V
pip 23.0.1 from C:\python310\lib\site-packages\pip (python 3.10)

# Make
G:\all_flask
λ python -m venv test_env

G:\all_flask
λ cd test_env\

G:\all_flask\test_env
λ G:\all_flask\test_env\Scripts\activate

# In venv old version
(test_env) G:\all_flask\test_env
λ pip -V
pip 22.0.4 from G:\all_flask\test_env\lib\site-packages\pip (python 3.10)

(test_env) G:\all_flask\test_env
So many time i leave it at old version(lazy) in venv as there rarely any issue.
To get the new version in venv,same as outside.
(test_env) G:\all_flask\test_env
λ python -m pip install --upgrade pip
Requirement already satisfied: pip in g:\all_flask\test_env\lib\site-packages (22.0.4)
Collecting pip
  Using cached pip-23.0.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.4
    Uninstalling pip-22.0.4:
      Successfully uninstalled pip-22.0.4
Successfully installed pip-23.0.1

(test_env) G:\all_flask\test_env
λ pip -V
pip 23.0.1 from G:\all_flask\test_env\lib\site-packages\pip (python 3.10)
Reply
#3
Thank you for the verification. I will update the steps to ensure that pip upgrade is part of the process. One reason to use the upgrade is because the I had an issue with install which weren't fixed until I upgraded.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  my venv is not loading njoki 1 263 Mar-20-2024, 10:41 AM
Last Post: snippsat
  run part of a script with a different version of Python jdog 2 461 Jan-09-2024, 08:49 PM
Last Post: jdog
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 752 Oct-04-2023, 10:01 AM
Last Post: snippsat
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 2,291 May-10-2023, 02:13 PM
Last Post: Calab
  How to resolve version conflicts in Python? taeefnajib 0 935 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  Python Version upgrade nitinkukreja 1 913 Feb-04-2023, 10:27 PM
Last Post: Larz60+
  Visual Studio Code venv ibm_db error mesi1000 7 2,834 Nov-13-2022, 12:36 AM
Last Post: snippsat
  Can't update new python version on Pycharm GOKUUUU 6 3,870 Jul-23-2022, 09:24 PM
Last Post: GOKUUUU
  Building python (3.9.5) with different libexpat version (2.4.6) raghupcr 0 1,321 Feb-25-2022, 11:29 AM
Last Post: raghupcr
  Python keeps running the old version of the code quest 2 3,789 Jan-20-2022, 07:34 AM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

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