Video Coming Soon...

Created by Zed A. Shaw Updated 2024-12-10 18:57:40
 

39: Beyond Jupyter for macOS/Linux

Jupyter is a great environment for interactive analysis. You can load your data, mess with it, refine it, generate graphs, add documentation, and even edit files. For most daily work an analyst does that might be enough, but Jupyter has a few limitations:

  1. It's difficult to share your analysis with other people in a way they can reuse. Sure, you can give them a notebook to look at, or publish online in various ways, but there's no ability to import a Jupyter notebook the way you can easily import a Python module.
  2. Jupyter notebooks tend to promote "copy-pasta code", which means you'll more often copy-paste the common code you need in every notebook, or just keep a stock template notebook around with your usual setup. That works for a while, but eventually it degrades, especially if you find a bug and now have to go through every notebook fixing the bug in all your copy-paste code. It's far more efficient to take you common "boilerplate" code and place it in a module you import. This also makes something you can share with other people who might need to work with the same systems as you.
  3. You can't run automated tests on a Jupyter notebook. Automated tests are an amazing resource for ensuring your code keeps working as you make changes, and help other people who use your code confirm it's working. The primary area you'll find this useful is when you do data munging. Data tends to be gross and change often, so tests confirm your code keeps working when you have to update various data models.
  4. 98% of other programmers do not use Jupyter. If you're working on any analysis that you plan on giving to a programmer you'll need to "formalize" it into a Python project they can grab and use. If you can create a basic project, place it in their favorite version control system, and write some documentation, then they can usually improve it for you. If you just throw them a Unititle.ipynb before going on vacation for a month you will be hated with all the passion of a thousand dying Suns. Or just ignored. Depends on where you work.
  5. Another benefit of turning your Untitled.ipynb into a formal Python project is perspective. Many times something you thought was very good changes when you translate it to another language, platform, or medium. You might think your analysis is amazing and then you convert it to a Python module only to find that it's total junk, or could be far more efficient. This is similar to how painters look at paintings upside down to find errors, or musicians listen to their songs in cars. A change of perspective will almost always show ways you can improve the work.
  6. The most important reason to learn how to code Python without Jupyter is independence. I don't indoctrinate people in my educational style because I feel it's wrong to create students who depend on specific products, companies, languages, or communities. I want you to be able to migrate from one technology to another as the fashion of programming changes, because this really is a fashion industry. One day, Python and Jupyter is the best thing ever, and the next day everyone is on some new hot technology an "influencer" raved about in a Youtube video. If you want a long career in this industry you do not want to be dependent on anything, and the first step to this independence is learning how to use your computer like a programmer.

Does this mean you should not use Jupyter? No, Jupyter is awesome for doing your analysis and figuring out what to write. I want you to be able to use both Jupyter and other systems depending on what you need to do, and to accomplish this goal I will teach you the basics of the command line.

OSX Troubles

If you are using OSX (macOS) you may be forced to use a different shell called zsh. You should be able to use all of these commands with zsh, but if you want to use bash then you can force OSX to use bash. Type this command in Terminal:

chsh -s /bin/bash

Then log out of your computer completely and log back in. If it worked then you should be able to type:

echo $SHELL

That command should print out "/bin/bash" and you're done.

Previous Lesson Next Lesson

Register for Learn Python the Hard Way, 5th Edition (2023-2024)

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.