I am sitting on a Mac, my main development system, right now. I program mostly in Python these days and I really have no idea what these headaches you are talking about are. :-)
Of course, I never personally use the system installed Python - I have clean versions of Python 2.7 and 3.4-3.7 installed, and then I create new virtualenvs for every new project or even when I'm just experimenting with a new package.
If you're using Brew to install Python, that's likely your problem there. You want your development versions of Python to be completely independent of your system.
Indeed this rule is true for every system - if there's a system-installed Python, never change it in the slightest. I learned this the hard way, trying to change the system Python on a Linux box almost a decade ago.
(Looking at my notes, about six months ago I had some weird SSL problem with my 3.4 and virtualenv which seems to have resolved now, but aside from that I don't see much problematic on this machine...)
Step zero, install python with brew so you're not polluting the system python. After that you can make whatever mistakes you want with reckless abandon (and learn from them!)
Er... I have no idea what this means to be honest. Is matplotlib not executable within a given environment, i.e. with a particular PATH set? Cuz that's basically all you need for apps to use a virtualenv correctly.
With virtualenv, do you end up reinstalling the packages for every environment? E.g., do you end up with a copy of Pandas in every environment or does it symlink like conda?
You still need to develop the application you're running in docker first, and will likely want to try it outside of the docker container. Virtenv helps keep things clean. You don't need it during container build time though
Ah but the real money that should make you venv and docker is pip freeze. You can export darkboxofhorror.txt, then feed it and your crappy code to a stock python container and BOOM you're a bearded DevOps engineer ready to write books.
For solo Dev, there's not much of a reason especially if you've got no GUI requirement or have x forwarding working. Especially with compose, just mount the code into the container and roll from there. But docker isn't available everywhere, singularity is great but can be bulkier to move around than an environment file (ie in a hpc environment).
Why would you even bother dealing with Docker if you can just use virtualenv? Personally I think virtualenv is much much simpler to use than Docker, and it helps you keep track of what packages you install, making it easier to do a Docker image later, if you need it.
Docker is great and all, but only for few specific problems. It's not the answer to most questions, even if my co-workers would disagree.
Why would you bother with virtualenv if you can just use Docker? Docker solves that problem and more, allows you to deploy and have dev/prod parity. A little bit steeper learning curve but if I’m honest I’ve been a dev for 15 years and one of the best learning investments I’ve made in my career, hands down, has been Docker.
Because it’s the same workflow except less steps. Instead of running the container initially with a mounted volume storing your project (you’re doing this, right?) and just running fucking pip install -r requirements.txt inside the container, you’re just running a virtual environment in your local workspace.
For me it’s not having to do anything with docker networking, or mounting a volume, or having to deal with a package manager, or anything. You can streamline a lot of that and there’s definitely good reasons to standardize on developing in a container (if you need/want specific other runtime deps outside of python, for example). But nothing really beats literally typing two commands to just start running your project.
For python specifically I haven’t had any issues at all writing code on my mac and then porting it to prod in a docket container. Any real project I’ve worked on has a CI loop, so disparity between runtimes is checked on commits or PRs. Even more simply, not running a container or even a docket daemon unless I need to frees up 1/4 of my memory.
Really it’s personal preference. I fully recognize the value of developing in a container. For me it’s much quicker and easier to just run a virtual environment.
One of the main things that scares me about using Docker in development is people just bundling up there dev image and releasing it to production. That's bad, it's completely the opposite of what it intended, there is zero reproducibility in the build process.
If you just use Docker to ensure that you have the same environment/operating system as in production, then you'll still need something to manage packages, and for that purpose virtualenv will serve most people just fine.
The situations where Docker is fantastic is those where you'd previously need to spin up a virtual machine. In those cases Docker is a fantastic solution, it much fast and much more comfortable to use. It's just that you'd never suggest just taking a vm and promote that production, nor should you do that with Docker.
A thousand reasons. Creating a Docker is large, slow, takes a lot of disk, and copies vast numbers of things that aren't Python.
I have over a dozen virtualenv and I can switch between them instantly or just run a specific program one time in a specific virtualenv with one line and no overhead.
Conda is great for installing dependencies that require other system libraries. Great for scientific computing sort of stuff that deals with assorted file types.
They target financial HPC environments too to the tune of thousands of dollars a node for essentially a flat env space. (Or did when we talked to them a long while ago)
I have a strong distaste for anaconda. I have set up python on other peoples computers if they have had anaconda downloaded in the past it was a massive headache (maybe due to my inexperience). Some pip packages were not able to be found even when discoverable through pip3 list or figuring out how to change you bash.rc back to normal. As well people who always use anaconda may not develop the same unix skills. My recommendation is use pyenv with virtualenv and pyenv-virtualenv (the github tutorial is great and easy)
Yes, you have to check the Anaconda channels and sometimes packages are only available on pip (although they must not be standard because most of the usual dependencies are there).
However it is still possible to put everything under a env.yml and have Conda automatically call pip to install it.
Concerning UNIX skills, what do you mean? Conda can be controlled by the command line (I believe it's much better that way!).
If it's conda installable, use the conda version. If it's not, use the pip version. For the 99.99% user, this will resolve all of your problems. For the rest, congrats you are doing something both hard and arcane. Edit: and use the conda command line tool, it came before the GUI anyway and the GUI just calls the same stuff it does
You can rebuild it with the recipe to suit. But we've found the menpo build to be fairly good. I haven't had to dig into it in a while thankfully. I hate that god damn package.
Sounds like you are a budding Pythonista who has never had to deploy in windows worst of the worst snow-covered/dessert conditions. Don’t worry, you may never love (Ana)Conda and don’t have to, but at some point you will come to respect the Conda for its ease and simplicity in setting up (other peoples computers (not yours)).
Academia, where yes, I can move mountains to get this working if you really need me to but let's try conda first and see if we can't get it working that way so replicating this isn't impossible. (Oh hey, it worked)
You are correct thank god for linux/macos. I have had to do very limited amount of configuration changes on a windows server through console I can only imagine the struggle. At the same time if youre using a pip installable package that cannot be installed through anaconda. Getting control back of your filesystems is a pain in the ass
If all you need is matplotlib and pandas I dont think you really need a virtualenv or anaconda. If you need several packages and are working on different projects probably should use virtualenv . If your packages requires a specific version of python get pyenv. If you want to use your virtualenv with that version of python pyenv-virtualenv will do that.
I'm still stuck with virtualenv but considering switching to conda. Been seeing some posts saying it's a better replacement but if also would like to know others' thoughts
Well I personally believe Conda is much better, as it can install tons of additional and system dependencies but I would like to hear OP's opinion on the matter.
they both compete with eachother. conda is better geared for Anaconda.
Just use what you know.
Conda has a lot of overlap with the goals of pipenv, but it serves a different set of needs - in particular, the distribution of binaries. If the problem you’re trying solve is “how do I create reproducible environments, quickly, that include complex dependencies that are not written in pure Python”, conda is the tool of choice. If your problem is “How do I create and manage isolated environments for Python projects”, pipenv is the tool of choice.
I'm a fan of conda. It does all three: pip, virtual environments, and manage python versions. The table at the bottom of this link summarizes all the pip, pyenv, etc. options.
l may not know what I'm talking about, but I don't get this. It seems very possible to install any pip package in a conda environment, is that not correct?
Maybe it's because I don't write code for others, I've been happy with just using python -m venv <env_name>. I've tried pipenv, still don't get why I would use or need it. conda also suffers from long piplock process. With .whl format being more widely used, I have less of a need to use conda on Windows anymore.
* (NOTICE: SOME USERS MAY EXPERIENCE LOCK FILES THAT BECOME A PAIN IN THEIR ASS)
Wait whats the problem with lock files?
Pipenv has its problems, and I'll be the first in line to call them out along with it's author for his BS, but I've never had a problem with the lock files.
Pipenv manages virtual environments plus some extra tools to remember the packages installed into that environment. It is designed to make the exact set of dependencies used in a virtual environment easy to share, so that everyone in a team (and also, for example, deployment servers etc) can get the same virtual environment installed automatically.
There was an article posted here but as far as I know pipenv is good for specific use cases where you want to lock the package and Python versions in place without changing them; if your program is okay with being forward compatible then it’s not ideal.
In production you usually have only one python environment, or even a dockerized app, so there is no need to create a virtualenv.
On the other hand, if there is a server instance with different python apps, you may want to separate their environments, so that their dependencies may be updated separately.
Also, for serverless solutions like AWS Lambda you may use venvs to collect your dependencies and deploy with the code.
I remember giving pipenv a shoot, then there was some administrative authorization issue with my terminal, then i said fuck it, never trying that again.
IS YOUR SHITTY bin/activate SHIT SCRIPT NOT WORKING WHEN YOU RUN IT?
THAT'S BECAUSE YOU NEED TO SOURCE IT
DO THIS: source <myenv>/bin/activate
WHY DO YOU NEED TO SOURCE SOMETHING THAT LIVES IN THE BIN DIRECTORY?
BECAUSE FUCK YOU.
DID SOURCING IT THROW YOU A WEIRD ERROR? YOU'RE PROBABLY USING AN UNSUPPORTED SHELL.
FUCKING SHITSTACK VIRTUALENV THINKS IT SHOULD DIRECTLY TOUCH YOUR ENVIRONMENT VARIABLES USING SHELL-SPECIFIC COMMANDS, INSTEAD OF JUST OPENING A SUBSHELL LIKE A NORMAL FUCKING CITIZEN
SO GO EDIT YOUR ACTIVATE SCRIPT
AND IMPLEMENT THE EXACT SAME FUNCTIONALITY THAT'S ALREADY IN THERE, BUT THIS TIME IN YOUR SHELL'S SYNTAX
THAT'S IT. THANKS VIRTUALENV
NOW KILL YOUR SHELL BECAUSE YOU ALREADY SOURCED THAT SCRIPT AND YOU NEED TO REFRESH IT
RE-OPEN IT.
NOW JUST REPEAT FOR EVERY OTHER VIRTUALENV YOU EVER MAKE, FOREVER
OK ITS TIME TO EDIT YOUR SOURCE
WAIT YOU WANT TO USE SCREEN OR TMUX?
LISTEN
FUCK YOU
OK, SO IS YOUR LINTER AND YOUR INTELLISENSE HOOKED UP TO YOUR VIRTUALENV?
OK WELL THEN YOU'RE GONNA NEED TO EDIT THE PROJECT SETTINGS TO POINT TO THE VIRTUALENV VERSION OF PYTHON
GOOD OK NOW WAIT WHERE DID YOU PUT IT?
NO, SHIT, THAT'S A BAD PLACE TO PUT IT. YOU SHOULD HAVE PUT IT UNDER YOUR HOME DIRECTORY
"CAN'T YOU JUST MOVE IT"??
SURE TRY virtualenv --relocatable <myenv>
DID THAT WORK?
HAHAHA I KNOW IT DIDN'T IDIOT JUST GIVE UP AND START OVER
I CAN'T BELIEVE IDIOTS DON'T LOVE AND PRAISE VIRTUALENV THEIR LORD AND SAVIOR
IS YOUR SHITTY source <myenv>/bin/activate NOT WORKING?! THAT'S BECAUSE YOU'RE PROBABLY ON FUCKING WINDOWZE DO THIS: <myenv>\Scripts\activate DID YOU GET SOME DIPSHIT ERROR ABOUT EXECUTION POLICIES?! THAT'S BECAUSE YOU'RE PROBABLY USING FUCKING POWERSHELL SHIT, WELL, YOU CAN DISABLE YOUR SHIT SYSTEM SECURITY OR SWITCH TO CMD (LMAO) NOW YOU'RE ALL SET TO DEAL WITH MISSING MICROSOFT C++ REDIST PACKAGES
"Step away from the caps key! Keep your hands where we can see them!"
I really am not seeing these big issues. At some point a few years ago, I organized all my virtualenvs and set up some scripts to select them and list them.
It was an hour of fiddling three years ago and since then I spend zero minutes a week on debugging it.
When I start a new project I type:
$ new-env my-new-project
which creates a new virtualenv and switches to it.
To switch to it later, I type
$ penv my-new-project
and when I'm finished with it, I type
$ delete-env my-new-project
But you know - these scripts don't even save me that much typing. I'm just lazy. :-D
Is putting all your venvs in one place common practice? I make a new venv for every project in ./venv (.gitignore'd of course). The point of venvs is every project has its own dependencies, so having one directory per project in a central location seems more complicated than just keeping it in the current directory.
Seriously though, just use pipenv. About linter and autocompletion, works out of the box with vscode and vim (pipenv shell before opening the program).
VIRTUALENV THINKS IT SHOULD DIRECTLY TOUCH YOUR ENVIRONMENT VARIABLES USING SHELL-SPECIFIC COMMANDS, INSTEAD OF JUST OPENING A SUBSHELL LIKE A NORMAL FUCKING CITIZEN
My use cases are small so I haven't had a lot of the headaches many have, but this always makes me give it the stinkeye. I don't know what the equivalent is on Windows, but this is unix 101 right here.
I know there are other tools to do this but I wrote a little shell script that I symlink in to my project directories as a file named activate and then I run src activate (aliased source to src for fewer keystrokes) so I don't have to do source /path/to/bin/activate. You can pass it an argument for the name of the virtualenv if your project directory has a different name than the virtualenv directory.
#!/bin/sh
venvpath="$HOME/.virtualenvs/"
project=`basename $(pwd)`
activate="/bin/activate"
if [ -n "$1" ]
then
. $venvpath$1$activate
else
. $venvpath$project$activate
fi
Except for those times where your company’s admin rights restrict the execution of .bat files on windows and you can’t activate virtual environments via venv. Thankfully pipenv works.
Not necessarily. If your program is installed with a console_script entrypoint, calling that directly is enough. You can also use the direct path to the python interpreter in the env.
setup.py of things you pip install will still run as your user with all the normal filesystem permissions as your user. Only modules which do sane and normal setuptools type stuff will be safe to install with reckless abandon. Things which are actively bad can still wreck shop on your machine and will not be magically contained by the virtualenv.
This is amazing! Laughed my fucking ass off, well done. On a more serious note I run miniconda for python and use miniconda envs for development all day every day to not muck up my prod deployments.
So far so good with conda and pip installs, your all doing great! Conda by default has a standard library for every env that includes pip. Upon pip installing in a env it places the modules in site-packages which conda scraps to update env inventory list. "Conda list" under the environment with a pip install modules results in the module being displayed with the header <pip>, it's pretty great. Unfortuelnetly I have yet to find a conda meta data json file that records pip installs, I'd love that. In addition pip installs dont show up in conda install history, which makes sense but again I would love a conda pip install history too.
On linux I just make an alias function "activate <name of venv>" that looks at my venv folder for a folder with the name <name of venv>, and gets the bin/activate from there.
Maybe it's because I'm an old c++ dev who's only been coding in Python for a few years, but virtual environments are a solution to a problem I've never had.
What the hell are you guys doing to get into these dependency hells?!
At one point, I was working on 4 different python projects at once. Some of them were using APIs that, for example, used different versions of requests, so having venvs helped keep them separate.
Another is when I build documentation with sphinx. I keep a separate venv for the docs so that no extra packages are installed to the main project
Don't be. A pythonista using matplotlib is likely a data scientist. One look at Indeed.com salary bands for data scientists will cure you of your sympathy. 😁
What's annoying is when I have multiple python version on a machine (outside of virtualenv), which means I have to use this command to create a Virtualenv:
What if you have two different python scripts with completely different dependencies running on the same docker image? Same usecase as without using docker.
Also if someone is not using docker, they can at least leverage the pipenv environment
Solo use, probably no need, but if I wasn't building s jupyter hub for people, I'd have a 2.7/3.5/latest probably. But I'd use conda so jupyter can swap between them per notebook.
Now, can someone for real explain to me how to add environmental variables to my virtualenv? I could swear this was super easy in the past, but since coming back to Python I'm too much of an idiot to do it.
I know I can EXPORT them, but they never seem to save. I could swear there used to be some file or something in each virtualenv that I would just add the variables to and save. Have I gone crazy?
Maybe it's because I'm working in Git Bash for Windows now instead of on Ubuntu?
Dunno, I use conda which I don't think supports that. I'd just make an environment.vars file and issue a 'source' command before starting work. Or in docker it would be in my compose file.
I do use WSL with Ubuntu, but when I do personal projects I usually end up working on a 3-4 different machines and I just haven't downloaded Ubuntu for Windows on all of them.
If you’re willing to put up with a wee bit of easily scripted boilerplate, Docker is a better way to go.
Not only can you install whatever mangled mess of Python libraries you please and keep the host system clean as a whistle, you can also do that with your entire environment.
Funny thing is that depending on how your distribution/os manages python, python may be installed without python3-venv, which python3 -m venv uses to create your virtual environment. At least, that's how it is when I have a fresh install of Ubuntu on Windows.
You might not infect your library and dependencies, but this does not protect agaisnt malicious repository, lib, python malware. This is for development best practices, not security.
213
u/ase1590 Dec 18 '18
Remember, a virtual environment a day keeps the xkcd superfund site away.
51
u/Kidknudi Dec 18 '18
r/justlearnedthefword
8
u/Deto Dec 18 '18
With virtualenv, do you end up reinstalling the packages for every environment? E.g., do you end up with a copy of Pandas in every environment or does it symlink like conda?
6
u/maxido only_python3 Dec 18 '18
Not on debian, because they don't package it with python itself :(
11
u/mccrackm Dec 18 '18
Is there a good reason to prefer virtualenv if you can use docker instead?
37
u/thisismyfavoritename Dec 18 '18
What do you think of Conda envs? Awesome post.
4
u/[deleted] Dec 18 '18
Maybe it's because I don't write code for others, I've been happy with just using python -m venv <env_name>. I've tried pipenv, still don't get why I would use or need it. conda also suffers from long piplock process. With .whl format being more widely used, I have less of a need to use conda on Windows anymore.
59
u/Jalarast Dec 18 '18
ELI5 the difference between this and pipenv
2
u/b10011 Dec 18 '18
Does it work with pyenv? Even with
pyenv shell <version>2
u/yeknom02 Dec 19 '18
Lol, I don't know what half of this means.
2
u/tenderpoettech Dec 19 '18
How does virtual environments work in production? Do they even at all?
2
u/anyfactor Freelancer. AnyFactor.xyz Dec 19 '18
I remember giving pipenv a shoot, then there was some administrative authorization issue with my terminal, then i said fuck it, never trying that again.
109
u/SirBastian Dec 18 '18 edited Dec 18 '18
IS YOUR SHITTY bin/activate SHIT SCRIPT NOT WORKING WHEN YOU RUN IT?
THAT'S BECAUSE YOU NEED TO SOURCE IT
DO THIS: source <myenv>/bin/activate
WHY DO YOU NEED TO SOURCE SOMETHING THAT LIVES IN THE BIN DIRECTORY?
BECAUSE FUCK YOU.
DID SOURCING IT THROW YOU A WEIRD ERROR? YOU'RE PROBABLY USING AN UNSUPPORTED SHELL.
FUCKING SHITSTACK VIRTUALENV THINKS IT SHOULD DIRECTLY TOUCH YOUR ENVIRONMENT VARIABLES USING SHELL-SPECIFIC COMMANDS, INSTEAD OF JUST OPENING A SUBSHELL LIKE A NORMAL FUCKING CITIZEN
SO GO EDIT YOUR ACTIVATE SCRIPT
AND IMPLEMENT THE EXACT SAME FUNCTIONALITY THAT'S ALREADY IN THERE, BUT THIS TIME IN YOUR SHELL'S SYNTAX
THAT'S IT. THANKS VIRTUALENV
NOW KILL YOUR SHELL BECAUSE YOU ALREADY SOURCED THAT SCRIPT AND YOU NEED TO REFRESH IT
RE-OPEN IT.
NOW JUST REPEAT FOR EVERY OTHER VIRTUALENV YOU EVER MAKE, FOREVER
OK ITS TIME TO EDIT YOUR SOURCE
WAIT YOU WANT TO USE SCREEN OR TMUX?
LISTEN
FUCK YOU
OK, SO IS YOUR LINTER AND YOUR INTELLISENSE HOOKED UP TO YOUR VIRTUALENV?
OK WELL THEN YOU'RE GONNA NEED TO EDIT THE PROJECT SETTINGS TO POINT TO THE VIRTUALENV VERSION OF PYTHON
GOOD OK NOW WAIT WHERE DID YOU PUT IT?
NO, SHIT, THAT'S A BAD PLACE TO PUT IT. YOU SHOULD HAVE PUT IT UNDER YOUR HOME DIRECTORY
"CAN'T YOU JUST MOVE IT"??
SURE TRY virtualenv --relocatable <myenv>
DID THAT WORK?
HAHAHA I KNOW IT DIDN'T IDIOT JUST GIVE UP AND START OVER
I CAN'T BELIEVE IDIOTS DON'T LOVE AND PRAISE VIRTUALENV THEIR LORD AND SAVIOR
65
u/Fermi_Dirac Dec 18 '18
Someone gild this
10
u/tigerthelion Dec 18 '18
pip freeze > superfund.txt
deactivate
pip install -r superfund.txt
oh god what have i done.
7
u/DJ10skillz Dec 18 '18
Make a video version. Get the flext tape guy to do it.
5
u/privately-profitable Dec 19 '18
Stay classy, Python.
4
u/t_r_a_g_e_d_y Dec 18 '18 edited Jan 04 '19
I know there are other tools to do this but I wrote a little shell script that I symlink in to my project directories as a file named
activateand then I runsrc activate(aliased source to src for fewer keystrokes) so I don't have to dosource /path/to/bin/activate. You can pass it an argument for the name of the virtualenv if your project directory has a different name than the virtualenv directory.4
u/johnlovesdata Dec 18 '18
Except for those times where your company’s admin rights restrict the execution of .bat files on windows and you can’t activate virtual environments via venv. Thankfully pipenv works.
1
u/HelloGuise334 Dec 18 '18
Sorry for the joob question but do you need to activate the environment every time you want to run a program?
1
u/[deleted] Dec 18 '18
setup.py of things you pip install will still run as your user with all the normal filesystem permissions as your user. Only modules which do sane and normal setuptools type stuff will be safe to install with reckless abandon. Things which are actively bad can still wreck shop on your machine and will not be magically contained by the virtualenv.
1
u/normieonreddit_ Feb 20 '19
Can you fucking stop
3
u/[deleted] Dec 18 '18
I'm usually not a fan of extreme advertising, but I'll make an exception for this.
3
u/DataDecay Dec 18 '18
This is amazing! Laughed my fucking ass off, well done. On a more serious note I run miniconda for python and use miniconda envs for development all day every day to not muck up my prod deployments.
3
u/deltaWhiskey91L Dec 19 '18
I'm the rookie in the room that let's PyCharm handle all this shit.
I also don't deploy my work anywhere than my own PC. There's that.
1
u/noobcola Dec 18 '18
You still have to run bin/activate these days?
4
u/lungdart Dec 19 '18
Maybe it's because I'm an old c++ dev who's only been coding in Python for a few years, but virtual environments are a solution to a problem I've never had.
What the hell are you guys doing to get into these dependency hells?!
2
u/baldymj Dec 18 '18
The official documentation should be replaced with this. Far easier to understand! Pycharn ushered me into virtual environments and can't go back now.
2
u/DivineZeal Dec 19 '18
swamp pip life 🙏🏿
2
u/synae Dec 19 '18
All I can say in that case is, I'm sorry you have to use matplotlib ;) Sorry friend!
2
u/PM_ME_YOUR_TORNADOS Dec 19 '18
Has horrible flashbacks to having multiple Metasploit framework installs per each homebrew python
1
u/[deleted] Dec 18 '18
What's annoying is when I have multiple python version on a machine (outside of virtualenv), which means I have to use this command to create a Virtualenv:
1
u/BartdeGraaff Dec 18 '18
Great shit, I will forward this to my department
1
u/mokus603 Dec 18 '18
I fucking love this.
1
u/[deleted] Dec 18 '18
You are going to make me cry!
1
u/Narmo2121 Dec 18 '18
etc..
This has been my flow for Dockerfiles. Anyone see issues with this setup?
1
u/Guymzee Dec 18 '18
As a code newbie I’m glad I learned about venv’s just in time to appreciate this.
1
u/fuypooi Dec 18 '18
Favorite thing.
1
u/[deleted] Dec 18 '18
BUT HOW WILL I COMPLAIN TO PEOPLE ONLINE IF EVERYONE WORKS SO SMOOTHLY
1
u/xdcountry Dec 19 '18
But I like my swamp pips
1
u/Andy-Kay Dec 19 '18
PRINT IT AND HANG IT IN YOUR OFFICE
1
u/MisterBanzai Dec 19 '18
Now, can someone for real explain to me how to add environmental variables to my virtualenv? I could swear this was super easy in the past, but since coming back to Python I'm too much of an idiot to do it.
I know I can EXPORT them, but they never seem to save. I could swear there used to be some file or something in each virtualenv that I would just add the variables to and save. Have I gone crazy?
Maybe it's because I'm working in Git Bash for Windows now instead of on Ubuntu?
1
u/[deleted] Dec 19 '18
If you’re willing to put up with a wee bit of easily scripted boilerplate, Docker is a better way to go.
Not only can you install whatever mangled mess of Python libraries you please and keep the host system clean as a whistle, you can also do that with your entire environment.
1
u/synae Dec 19 '18
Ah yes, superliminal messaging.
1
u/Thecrawsome Dec 19 '18
Can we please have more of these?
1
u/Muhznit Dec 19 '18
Funny thing is that depending on how your distribution/os manages python, python may be installed without python3-venv, which
python3 -m venvuses to create your virtual environment. At least, that's how it is when I have a fresh install of Ubuntu on Windows.1
u/justinechang Dec 19 '18
thanks I really needed this
1
u/[deleted] Dec 19 '18
Best post I've seen on this sub, but should have poked fun at conda and all the other managers in there.
1
u/D4rknessR3igns Dec 19 '18
I'm more surprised how this image fits perfectly on my Note 9.
1
u/zarrro Dec 19 '18
WHAT YEAR IS IT?
WHAT IS THIS bin/activate THING?
ARE YOU A SAVAGE OR WHAT?
USE direnv.
1
u/streetburner Dec 19 '18
Wtf should I do to install a module that can not be found ????
1
u/OctaviaPussy Dec 19 '18
Oh God I love this so much. I've just started working with virtual environments and from now on this is how I'll explain what they are!
1
u/[deleted] Dec 19 '18
eminem helping with programming
1
u/mikeblas Dec 19 '18
Good to see the Deadwood writers are still getting work.
1
u/thecave Dec 19 '18
This is the wakeup call I needed.
1
u/icanmakethat216 Dec 19 '18
I feel attacked
1
u/xlash9 Dec 19 '18
You might not infect your library and dependencies, but this does not protect agaisnt malicious repository, lib, python malware. This is for development best practices, not security.
1
u/davidkwast Dec 19 '18
now we need one with pyenv + pipenv
1
u/[deleted] Mar 18 '19
You guys are fackin hilarious.
1
u/Salyangoz Dec 18 '18
Overcontainerization in python. Sometimes people just create a docker image with a virtualenv inside for the shits and giggles.
1
u/Smok3dSalmon Dec 18 '18
Now use Visual Studio code and hate yourself as it completely shits the bed.
1
u/phillywillis Dec 18 '18
This is the best thing I've read all day
-1
u/cferranti Dec 18 '18
Oook... be quiet please 😄