Using sudo with pip3?

Cameron Simpson cs at zip.com.au
Sat Jan 7 19:48:51 EST 2017


On 08Jan2017 11:22, Chris Angelico <rosuav at gmail.com> wrote:
>On Sun, Jan 8, 2017 at 10:51 AM, Cameron Simpson <cs at zip.com.au> wrote:
>> Here's an example:
>>
>>  $ mkdir ~/var ~/var/venv  # where I keep my virtualenvs
>>  $ virtualenv -p /usr/bin/python3 --system-site-packages ~/var/venv/3
>>  $ ~/var/venv/3/bin/python3    # invokes the virtualenv python3
>>  $ ~/var/venv/3/bin/pip3       # invokes the virtualenv pip3
>>  $ ln -s ~/var/venv/3/bin/python3 ~/bin/.  # make these my default
>>  $ ln -s ~/var/venv/3/bin/pip3 ~/bin/.
>>
>> From this point on "pip3" should execute your own $HOME/bin/pip3, which
>> comes from the virtualenv and installs in ~/var/venv/3/lib/...
>
>Can you do the same with the standard library 'venv' module? I
>generally recommend and prefer that over the third-party 'virtualenv',
>which achieves what it does via a series of hacks.

Probably? Haven't tried. I thought the venv module was essentially virtualenv's 
innards presented as a module, but have never tested it.

Do I need to retire my "venv" shell script (convenience wrapper for the 
virtualenv command)?

Cheers,
Cameron Simpson <cs at zip.com.au>


More information about the Python-list mailing list