1

I used python3 -m venv to create a virtual environment, in that virtual environment my settings are:

python 3.5.2 pip 8.1.1 Mac OS 10.13.6

That pip version is extremely OLD and leads to a problem described below: how do I get venv to install a newer version of pip?

Whenever I run "pip install " I get an error of the form:

Could not fetch URL https://pypi.python.org/simple/<any_package>/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) - skipping 

I have tried this with = flask, gunicorn, and requests and believe that it's not a package specific problem.

What I tried to fix the problem:

I came across this link which suggested I should upgrade pip somehow: https://github.com/pypa/pip/issues/5226

So I upgraded pip up to the latest version: pip 20.0.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip (python 3.5)

But the problem persisted. So then I upgraded venv to the latest version.

But the problem persisted again.

I did some more research online and came across the following github issue: https://github.com/pypa/pip/issues/5363

Which had as part of the problem statement text very similar to my TLS issue, but none of the answers there seemed to be able to fix the problem (pasting each one resulted in the same TLS issue).

Finally I found something that worked:

From this question: Upgrading pip/installing django - [SSL: TLSV1_ALERT_PROTOCOL_VERSION]

The solution below:

 curl https://bootstrap.pypa.io/get-pip.py | python3 

Upgrades my "virtual enviromnet's pip" to the correct version. But I yet to figure out how to get my default pip (when I create a new virtual environment) to be up to date.

2

1 Answer 1

1

As of today, it is not possible.

Starting with Python 3.9 it should be possible to do something like path/to/pythonX.Y -m venv --upgrade-deps .venv, and that would upgrade pip and setuptools in the newly created virtual environment:

You could try virtualenv instead, if it suits your workflow better. As far as I know it tries to always install the latest version of pip in the virtual environments it creates.

There is an example of code at the end of venv's documentation showing how to create a tool that downloads and installs up-to-date pip and setuptools:

User wim made an interesting suggestion here:

I have a tool called ve that does something similar:

There are some answers to similar questions, suggesting to modify the wheel files bundled with ensurepip in Python's standard library, but I wouldn't recommend that.

Similar questions:

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.