3 ms·
I develop for both Python 2 and Python 3 on OS X and my setup is pretty similar to rgacote's. I installed both versions of Python using homebrew[0] so it doesn
by citruspi 11y ago
I develop for both Python 2 and Python 3 on OS X and my setup is pretty similar to rgacote's.
I installed both versions of Python using homebrew[0] so it doesn't matter which version OS X ships with.
Python 2 is still the default. So I have python and pip, and then python3 and pip3.
Every project I work on has a virtual environment[1], which is named after the owner and the project, e.g. citruspi-skynet.
If it's a Python 2 project, I just create the virtual
environment normally.
mkvirtualenv citruspi-skynet
If it's a Python 3 project, I set the location of Python interpreter.
mkvirtualenv -p $(which python3) citruspi-skynet
I've run into situations where I have to port a Python 2 project to Python 3, while maintaining the Python 2 project. In that case, I normally use the same repository, but a new branch. However, I'll keep two copies of the repository locally so I can work on both branches at the same time.
Code/
citruspi/
skynet
skynet3
And then I'll have two virtual environments, citruspi-skynet and citruspi-skynet3.
I haven't run into any issues with this setup and I've been pretty happy.
[0]: http://brew.sh http://brew.sh
[1]: https://virtualenv.pypa.io/en/latest/ https://virtualenv.pypa.io/en/latest/
- natch 11y agoThanks! Did not know about virtualenv, I'll try that. This is really good and detailed information; I appreciate it (and rgacote's too).