MacOS – the python-style equivalent of virtual environments but for a user account on a Mac OS

macos

I want to install different packages and software but I really don't like the idea of doing a sudo command to install anything.

I use Homebrew and MacPorts for getting any apps I need but is it possible to install applications, libraries and packages specific to a python style virtual environment and if I think I don't want these packages to collide, I can just delete a virtual environment or simply use a different environment?

Please let me know if the question does not make sense. Ever since I started using virtual environments in Python, I can't imagine not working with virtual environments and I was wondering if there is something equivalent or a pattern of installation that people recommend that would mimic that behavior?

ps> I know there is Fink also but I don't use it.


Version 2:
I think I need to verify my question further.
I already use virtualenvwrapper and do everything Python related in virtual environments. The question is independent of Python. Its just that virtualenv inspired me to see if there was an equivalent, user-account-wide.

What I figured would be awesome, came up when I was trying to install libjpeg, PIL, FreeType2, Pillow etc.
I wanted to install these libraries or packages like libjpeg, FreeType2 in a virtual environment of the OS. If I felt like the Homebrew version of these library installs was not to my satisfaction, I could just work in a different environment or try some other installation procedures and switch between environments of the installed applications.

So, I was wondering if something like that exists for OS X or are there some tricks one can do to emulate it?

Best Answer

If you are dead set on that paradigm, then virtual machines seems to be a logical next step, no? Grab Virtualbox and do your thing in a VM.

Note however that package managers solve many problems virtualenv addresses. The libs you mention won't change interfaces radically, they are stable releases.

It's python libs which are the most volatile, not things like FreeType. I would just use whatever version X11 is using.