4 ms·
The author concludes the best solution is using brew to install different Python dependencies for different packages. I had a similar solution when I started u
by ryan-duve 6y ago
The author concludes the best solution is using brew to install different Python dependencies for different packages. I had a similar solution when I started using a Mac for work back in 2017, but around six months ago I found another way:
1. Install Docker CE on the Mac.
2. Start a container for your work, e.g.,
docker run python:3.8
3. When you need to get back into it, use
docker exec -it <first_three_container_characters> ipython
4. If the container is shut down from a reboot or something, start it with
docker start <first_three_container_characters>
What's really cool about this is `bash` can be run instead of `ipython` to get a Bash prompt and install any Linux dependency. In theory, at some point if one project has conflicting dependencies with another project a new container can be spun up, but this is not something that's come up in practice yet.
This has worked so well for me these past few months, I actually replicated it on my Linux computer. I took a few extra convenience steps like mounting `/home/` and aliasing `ipython` to a command that starts the container before executing the command, but other than that it's been a pretty seamless experience and I never have to worry about OS-level Python installation stuff any more. I use a scipy image with Jupyter Lab in a similar way for my graphical notebook needs.
The only time I would recommend against this is when performance is an issue (like training ML models), but at work we use AWS machines with their own Docker environments for that. For everything else, Mac, Linux or maybe even Windows, Docker is the only way I now recommend firing up Python.
- TheRealPomax 6y agoAnd then enjoy the jet engine that your macbook fans turn into, because holy shit Docker is bad at resource management.
- vorpalhex 6y agoThis depends on your base image and what it's doing. If you're running like a large elasticsearch cluster.. you're still running a large elasticsearch cluster. Docker overhead should generally be minimal even with the VM that's running, but make sure to use alpine/slim images.
- powerapple 6y agoAgree. I have never enjoyed running docker on my laptop. If I have to use Docker, I use it on a remote Linux server. I had good experience with Vagrant if I have to use a linux environment locally. The only good thing with Docker on macOS is that you don't need to sudo it.
- Wowfunhappy 6y agoIs the problem that Docker is bad at resource management, or that this is just what happens when you're actually running an entire second OS under the hood? I appreciate Docker's approach, but it's definitely a bit of a nuclear option (at least on non-Linux systems).
- cutler 6y agoSurely it's an admission of failure if one has to resort to Docker just to get a scripting language to function on a local machine? It's only a matter of time before someone finds a use for Kubernetes on a local machine.