JP Vossen via plug on 20 May 2020 10:44:06 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] Fixing a Python library mismatch |
On 5/20/20 1:22 PM, brent timothy saner via plug wrote:
On 5/18/20 18:52, Fred Stluka via plug wrote:On 5/16/20 4:14 PM, Walt Mankowski via plug wrote:I think both venv and pyvenv are more than I need most of the time.Walt, Keep in mind that Python virtual environments are astonishingly lightweight. Much, much, much simpler than you might expect. I dodged them for a little while, as one more complication that I didn;t yet need. Not true. Really simple and really useful. I now use them for EVERY python project, no matter how small.
I love virtualenv, I don't install Ansible without it anymore, and that allows me to have a bunch of different versions when I need them.
Ansible is not what I'd call a light-weight venv (see example). I don't care. This is SO much simpler and easier than anything else! KISS!
This is what I do: 1. Deactivate any existing virtenv: `deactivate` 2. Create a virtenv: `python -m virtualenv ~/venv/ansible-2.9.2`3. Hack the prompt: `perl -i -pe 's/PS1="\(`basename \\"\$VIRTUAL_ENV\\"`\) ?\$PS1"/PS1="\\n(`basename \"\$VIRTUAL_ENV\"`)\$PS1"/;' ~/venv/ansible-2.9.2/bin/activate`
4. Activate the virtenv: `source ~/venv/ansible-2.9.2/bin/activate` 5. Install Ansible: `pip install ansible==2.9.2`Note in step 2 you need to watch out for older distros because you might get Python2. Experiment as needed.
<soap box>My step 3 results in a pretty hairy prompt, but I like it that way because it's 100% self documenting. YMMV. Example below.
``` (ansible-2.9.2) [root@drake:T1:L1:C5082:J0:2020-05-20_13:29:08_EDT] /root/ansible# du -hsc ~/venv/* 65M /root/venv/ansible-2.3.2.0.DEAD 75M /root/venv/ansible-2.4.3.0.DEAD 90M /root/venv/ansible-2.5.15 158M /root/venv/ansible-2.9.2 387M total ```T1 = pTTY, L# = nesting level, C# = command number in history, J# = background job count. And as long as I remember to hit an enter or 2 before starting a new/long command, the consecutive prompt dates can give me elapsed time if I need it and forgot to use `time`.
I can't tell you how many times I've pulled stuff out of my scroll-back buffer, sometimes from *days* ago, to answer some question or add data to some ticket. And *everything* is Just Right There. Copy, paste, done.
</soap box> Later, JP -- ------------------------------------------------------------------- JP Vossen, CISSP | http://www.jpsdomain.org/ | http://bashcookbook.com/ ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug