r/Python • • Aug 05 '19

Python's response to MATLAB

Post image
4.3k Upvotes

372 comments sorted by

View all comments

Show parent comments

4

u/PeugeotWaterface Aug 06 '19 edited Aug 06 '19

Post doc here. I was in exactly the same boat as you. I did my whole PhD (physical chemistry, so lots of spectroscopy data) in Matlab. Wanted to switch to python but also didn't want to deal with setting it all up.

I recently took the time to learn python so I could start my new projects fresh and I can only say I wish I had done it sooner. One of the biggest differences so far for me has been how much more organized my projects are.

Here's what I did: I spent an entire weekend reading every tutorial I could on how to set up a "good" workspace environment using python, and then chose what was best for me. In my case, I went with anaconda as it gives me everything I need. I use a conda environment for each individual project, and use conda to save the dependencies of that environment with one command. Also check out "cookie cutter" on github. It's a python code that you can use to make your projects organized. I love it.

Finally, as others have stated, spyder really made the switch easier. The big plus is the python console for quick code checks and the variable explorer for seeing your data just like in Matlab.

So, in summary:

  1. Anaconda (or miniconda) with conda environments to control your packages

  2. cookie cutter to create organized project directories

  3. spyder to write and test code

Bonus: I use jupyter notebook to do the data exploration using the code I write in spyder. Let's say I do an experiment, now I can make all my graphs in one jupyter notebook and do my analysis there. I can easily change the graphs on the fly. It's like PowerPoint for viewing graphs mixed with Matlab for changing graphs quickly. Definitely recommend.

Let me know if you need help.

Edit: just to be clear. When using anaconda, you don't need things like pip and pyenv. It does those for you.

2

u/Antouziast Aug 06 '19

Thanks! This sounds like my experience! For now that's the workflow I'm leaning towards. I want to be able to generate graphs easily when exploring data and showing it to colleagues/advisors.

Is debugging easy when using this setup?

2

u/PeugeotWaterface Aug 06 '19

For me, debugging with spyder is identical to how I did it with Matlab.

1

u/Antouziast Aug 06 '19

Merci! (Avec un pseudo comme le tien j'imagine que tu es français)

2

u/PeugeotWaterface Aug 06 '19

😂 t'es proche! J'habite en France mais je viens des USA. En fait, je suis ici pour mon post doctorat (et peut être plus après ca)

(désolé pour mon français)

→ More replies (1)