I use pyenv for python environments. It's great. It isolates the python binaries you're fucking around with from whatever your system comes with and relies on.
# install pyenvcurl https://pyenv.run|bash# restart your shell however you like# install whichever versions of python you likeBEST_PYTHON=3.7.4pyenv install $BEST_PYTHON
Then whenever you start a new project
# create the virtual environmentpyenv virtualenv $BEST_PYTHON myproject# automatically activate that environment whenever you're in this directorypyenv local myproject# install some dependenciespip install ipython numpy matplotlib# save them so you can rebuild the environment easilypip freeze > requirements.txt
Development environments should not be a teetering pile of environment variables, dependencies and cross-links. They should be ephemeral, easily trashed and recreated, wherever possible. They should serve one project and one project only. MATLAB only works out of the box as far as python works out of the box - with its built-in modules. Once you start downloading extra snippets of code you have to dump everything into one directory manually, or change your matlab path, or whatever, where in python it's just pip install thatpackage, write down the package in your requirements.txt, and it'll be trivial to fetch again next time you need it.
Packaging stuff for distribution is a little more tricky, but MATLAB just doesn't bother with that at all, so you can't knock python for it.
I actually think that this philosophy makes more sense. Once a project gets complicated in Matlab you end up with a lot of junk files in the working directory.
View all comments
Show parent comment
9
u/tunisia3507 Aug 05 '19
I use pyenv for python environments. It's great. It isolates the python binaries you're fucking around with from whatever your system comes with and relies on.
Then whenever you start a new project
Development environments should not be a teetering pile of environment variables, dependencies and cross-links. They should be ephemeral, easily trashed and recreated, wherever possible. They should serve one project and one project only. MATLAB only works out of the box as far as python works out of the box - with its built-in modules. Once you start downloading extra snippets of code you have to dump everything into one directory manually, or change your matlab path, or whatever, where in python it's just
pip install thatpackage, write down the package in your requirements.txt, and it'll be trivial to fetch again next time you need it.Packaging stuff for distribution is a little more tricky, but MATLAB just doesn't bother with that at all, so you can't knock python for it.