Getting pip into your Python 3 venv

Python 3.3 includes a built-in equivalent to the popular virtualenv tool for creating isolated Python environments. One difference with the built-in venv is that it doesn’t automatically install pip as virtualenv does. While I can understand the decision (given Python’s volatile packaging situation), it isn’t very convenient.

Here’s a Windows batch file that will remedy that, using the latest recommended way of getting pip. It depends on having curl in your path somewhere. Use it like you would virtualenv or venv, namely, by providing the path to where you’d like to create your new virtual environment.

@echo off

REM Python 3.3 pyvenv including pip.

if "%1" == "" goto :error

python -m venv %1
call %1\Scripts\activate

curl -O

curl -O

del setuptools-*.tar.gz

goto :EOF

echo Specify the path to the virtual environment you want to create.
echo venv my_env

Leave a Reply

Your email address will not be published. Required fields are marked *