Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the venv module gets you a different pip/setuptools version #395

Closed
JayH5 opened this issue May 14, 2019 · 3 comments
Closed

Using the venv module gets you a different pip/setuptools version #395

JayH5 opened this issue May 14, 2019 · 3 comments

Comments

@JayH5
Copy link
Contributor

JayH5 commented May 14, 2019

If you use Python 3's built-in venv module, you get a different version of the pip and setuptools packages than the latest installed in the images.

See here:

❯ docker run --rm -it python:3.7-slim bash
root@3dcf68819a98:/# pip list
Package    Version
---------- -------
pip        19.1.1
setuptools 41.0.1
wheel      0.33.1
root@3dcf68819a98:/# python -m venv venv
root@3dcf68819a98:/# venv/bin/pip list
Package    Version
---------- -------
pip        19.0.3
setuptools 40.8.0
You are using pip version 19.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@3dcf68819a98:/# python -c 'import sys; print(sys.path)'
['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']
root@3dcf68819a98:/# venv/bin/python -c 'import sys; print(sys.path)'
['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/venv/lib/python3.7/site-packages']
root@3dcf68819a98:/# ls /usr/local/lib/python3.7/site-packages
README.txt  __pycache__  easy_install.py  pip  pip-19.1.1.dist-info  pkg_resources  setuptools	setuptools-41.0.1.dist-info  wheel  wheel-0.33.1.dist-info
root@3dcf68819a98:/# ls /venv/lib/python3.7/site-packages
__pycache__  easy_install.py  pip  pip-19.0.3.dist-info  pkg_resources	setuptools  setuptools-40.8.0.dist-info

Similar older issue that was closed: #118
Relevant discussion: #365 (comment)

@wglambert
Copy link

Odd, it seems that the version of venv that comes built-in isn't the most recent, I can't find information in pip or Python release notes about the version they come with. But this is the venv source https://github.com/python/cpython/tree/3.7/Lib/venv/
from https://docs.python.org/3/library/venv.html
The __init__.py is a few months old

And the usage of the built-in venv is limited and doens't have any way to get the version or upgrade

root@5739dbcd587f:/# python -m venv
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]
            [--upgrade] [--without-pip] [--prompt PROMPT]
            ENV_DIR [ENV_DIR ...]

I'd come across this issue https://bugs.python.org/issue34556#msg324433
A Python dev notes that it's common to invoke an upgrade when using the built-in venv

You could also use the virtualenv module to get an explicitly latest version

root@59616c014e15:/# pip install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/4f/ba/6f9315180501d5ac3e707f19fcb1764c26cc6a9a31af05778f7c2383eadb/virtualenv-16.5.0-py2.py3-none-any.whl (2.0MB)
     |████████████████████████████████| 2.0MB 2.4MB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-16.5.0

root@59616c014e15:/# virtualenv venv
Using base prefix '/usr/local'
New python executable in /venv/bin/python
Installing setuptools, pip, wheel...
done.

root@59616c014e15:/# /venv/bin/pip list
Package    Version
---------- -------
pip        19.1.1 
setuptools 41.0.1 
wheel      0.33.4

Version 16.5 is the one with the latest release versions
https://virtualenv.pypa.io/en/latest/changes/#id4

upgrade pip from 19.0.3 to 19.1.1 pypa/virtualenv#1346
upgrade setuptools from 40.8.0 to 41.0.1 pypa/virtualenv#1346

@purificant
Copy link

Came across this as well. Can also be reproduced with:

FROM python:3.7-slim-stretch

# 19.1.1
RUN pip --version

ENV VIRTUAL_ENV=/venv PATH="/venv/bin:$PATH"
RUN python -m venv /venv

# 19.0.3
RUN pip --version

@wglambert
Copy link

This is really an upstream issue that is installing the version of pip bundled with Python. I had looked through the issues on https://bugs.python.org and didn't see anything relevant, so I'd recommend maybe making an issue about this upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants