I\'m in Kubuntu 14.04 , I want to create a virtualenv with python3.4. I did with python2.7 before in other folder. But when I try:
pyvenv-3.4 venv
The following worked for me on Ubuntu 13.10:
pyvenv-3.4 delme --without-pip
source delme/bin/activate
python -Im ensurepip --upgrade --default-pip
I got a solution installing python-virtualenv
sudo apt-get install python-virtualenv
and using
virtualenv --python=/usr/bin/python3.4 venv
Here's an approach that is fairly O/S agnostic...
Both the pyvenv
and python
commands themselves include a --without-pip
option that enable you to work around this issue; without resorting to setuptool
or other headaches. Taking note of my inline comments
below, here's how to do it, and is very easy to understand:
user$ pyvenv --without-pip ./pyvenv.d # Create virtual environment this way;
user$ python -m venv --without-pip ./pyvenv.d # --OR-- this newer way. Both work.
user$ source ./pyvenv.d/bin/activate # Now activate this new virtual environment.
(pyvenv.d) user$
# Within it, invoke this well-known script to manually install pip(1) into /pyvenv.d:
(pyvenv.d) user$ curl https://bootstrap.pypa.io/get-pip.py | python
(pyvenv.d) user$ deactivate # Next, reactivate this virtual environment,
user$ source ./pyvenv.d/bin/activate # which will now include the pip(1) command.
(pyvenv.d) user$
(pyvenv.d) user$ which pip # Verify that pip(1) is indeed present.
/path/to/pyvenv.d/bin/pip
(pyvenv.d) user$ pip install --upgrade pip # And finally, upgrade pip(1) itself;
(pyvenv.d) user$ # although it will likely be the
# latest version. And that's it!
I hope this helps. \(◠﹏◠)/
Quite similar to @prismalytics.io but for those of you who don't like running shell scripts from the web. You can, of course, use --no-index --find-links to point to local copies. Any recent pip wheel file will suffice, this just points to the current version on PyPI.
python3 -m venv --without-pip your_venv
source your_venv/bin/activate
curl 'https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl' > pip.whl
python -m zipfile -e pip.whl $VIRTUAL_ENV/lib/python3*/site-packages
python -m pip install --force-reinstall --upgrade pip