Reputation: 14033
Usually I use virtualenv
for python2.x. After some bitter experience with unicode
encoding/decoding clash, I decided to upgrade to 3.x, But I can't create a virtualenv using pyvenv.
$ pyvenv-3.4 env
Error: Command '['/home/user/delete_this/env/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
Also I'd be grateful if someone points to a good virtual environment for python3.x since I see a lot of options.
Upvotes: 2
Views: 2474
Reputation: 5659
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. \(◠﹏◠)/
Upvotes: 3
Reputation: 125
Why don't just directly use third-party virtualenv install by sudo pip3 install virtualenv
, because you are already familiar with it when using python2
Upvotes: 0