Louie Mac OS
Steps to fully setting up a new (or factory reset) Mac for Python data science and development. These steps are very opinionated and there are lots of other ways/tools to do this.
Homebrew
My current full time job is a cross platform position, with an emphasis on Macintosh support (Mac OS X Client and Server 10.5/10.6/10.7) and desktop engineering, this includes creating images. Jul 24, 2017 Whether you want to try out macOS, run Xcode or make a hackintosh you can use a virtual machine to get started on macOS. Remember the performance of macOS, particularly graphical support is very limited on a virtual machine so performance with graphical animations will be subpar compared to a real mac or hackintosh, but it will still get the job done.
- Install Homebrew
- Get the
tree
shell command:brew install tree
In order for Homebrew-installed tools to take precedence, include the following in your ~/.zshrc
file (you might have to create it yourself). Utopia, an essay mac os. Apple recently switched from bash
to zsh
as its default shell which is nice.
A Note on .zshrc
More recent versions of Mac OS have switched over to using zsh
as the default shell. If your version is older, it still uses bash
as default. In that case, you can make edits to .bashrc
or .bash_profile
.
Running (System) Python
- When you run
python
in Terminal, it will suggest using thepython3
command instead - When you run
python3
for the first time, it will request to install XCode CLT- This includes a copy of
git
, but it's probably out of date
- This includes a copy of
Set up Git / Github
The git
command is already enabled once you install XCode CLT, but we want to install an up-to-date version with Homebrew.
For example, on 2020-12-25, the copy of Git installed by XCode is git version 2.24.3 (Apple Git-128)
, but the current version on that date is actually 2.29.2
.
Download the sims 4 complete. The default configuration for this new Git is just using the Keychain Password Manager.
We want to add our name and email globally (i.e. to every repo we work on). We also want to enable colored output.
Now the configuration is as seen below (or via ~/.gitconfig
):
Now we just need to set up access to a specific Github account. First we generate a new SSH key:
Accept the default file location, and no passphrase.
If there isn't a file at ~/.ssh/config
, create it, and modify the file as below:
Then:
Copy the key to your clipboard:
and paste into the Github New SSH Key section.
Python Setup
Install pyenv
via Homebrew, for managing Python versions.
Add pyenv init
to ~/.zshrc
.
Safari for mac os x 10.4 11. Make sure you have the build dependencies (might be a little over-specified):
In Big Sur (OS 11.1) at the very least, installing new versions via pyenv
is a little broken with Homebrew, etc. So put the following in ~/.zshrc
:
You can then install other (non-system) versions of Python as shown below. This takes a little while since it is being built from source.
You can then change the version with pyenv global 3.8.6
or pyenv local 3.8.6
.
Managing Python Environments
We will use Poetry for environment management. First install poetry:
Then enable poetry completions with:
and the following in ~/.zshrc
(before compinit
):
To create a new poetry project, use the following
Why Not conda
?
Anaconda is a pretty popular distribution for Python (in data science). I used to use it exclusively, but stopped because:
- It's a little heavy for me (even
miniconda
) - I prefer to rely on
pypi
offical packages rather than the Anaconda cloud - It doesn't play nicely with Poetry -- or rather, Poetry doesn't play nicely with it
- I prefer having my Python versions separate from my project environments
Directory Structure
Set up a top-level directory in HOME
called code
. Dedicate a sub-directory per project/repo.
Fonts
We'll install Fira Code. To install on Mac, download the pack and Open the TTF files with FontBook. To enable on VSCode, paste the following in settings.json
:
See the definitions of stylistic sets.
Visual Studio Code
Install Visual Studio Code manually. You will need to add the code
command to your PATH
. Start Visual Studio Code, open the command palette, and choose Shell Command: Install ‘code’ command in PATH. You can then set VSCode as the default editor for CLI by putting the following in ~/.zshrc
:
Louis Macouillard Prints
The settings file I use is here.
New Project
Explicit steps for creating a new code project.
Suggested starting values in the pyproject.toml
file.
pytest
plugins
Here's some pytest
plugins I like to use:
pytest-randomly
: Runs the tests in random orderpytest-cov
: Integrates withcoverage
to see code coverage
Using iCloud
In case you like to use iCloud for documents rather than Google Drive/Dropbox/whatever. The path to the iCloud directory is ~/Library/Mobile Documents/com~apple~CloudDocs
, so it's easier to just symlink it to something prettier.
Python Library Support
Through trial and error, here are some things you need to do to use some popular python libraries. Some of these manual installs are due to working on Mac OS 11.2 (Big Sur), but I'm honestly not sure which.
Louie Mac Os 11
Pillow
pillow
is a dependency for a lot of popular visualization packages (e.g. matplotlib
). It relies on some external libraries that you can install via homebrew. pillow
documentation
Scipy
Useful in its own right. Also a dependency for numpy
and matplotlib
. It requires BLAS and LAPACK libraries. Docs here
Additionally, scipy
relies on pymssql
which needs
And finally when executing poetry add scipy
, as per this issue comment, you should use:
Anaconda
In case we are using Anaconda or Miniconda..
After installing Miniconda and setting it up, we want to prioritize the Conda Forge channel. Following these instructions use the following commands:
Resources
- This Dec 2020 guide for setting up a fresh Mac for software development
- This May 2019 guide to setting up VSCode
- 2020 Mac Setup: More general-purpose
ID | Name | Platform | Architecture | Single-core Score | Multi-core Score |
---|---|---|---|---|---|
7320995 | Dell Inc. XPS 13 7390Intel Core i7-10710U1596 MHz(6 cores) | Windows 64 | x86_64 | 1028 | 4614 |
6861787 | Samsung Galaxy Tab S7+ARM Qualcomm1804 MHz(8 cores) | Android 64 | aarch64 | 959 | 2986 |
6597093 | GenericAMD Ryzen 9 3900XT3793 MHz(12 cores) | Windows 64 | x86_64 | 1335 | 12607 |
6593692 | GenericAMD Ryzen 9 3900XT3793 MHz(12 cores) | Windows 64 | x86_64 | 1293 | 10648 |
6593644 | GenericAMD Ryzen 9 3900XT3793 MHz(12 cores) | Windows 64 | x86_64 | 1296 | 10688 |
6507289 | GenericIntel Core i5-104002892 MHz(6 cores) | Windows 64 | x86_64 | 1166 | 6089 |
6418904 | iPhone 12 ProApple A14 Bionic2990 MHz(6 cores) | iOS 64 | aarch64 | 1594 | 4066 |
6116381 | Mac mini (Late 2018)Intel Core i3-8100B3600 MHz(4 cores) | macOS 64 | x86_64 | 897 | 3396 |
5896023 | Mac mini (Late 2018)Intel Core i3-8100B3600 MHz(4 cores) | macOS 64 | x86_64 | 880 | 3249 |
3139404 | GenericAMD Ryzen 5 36003593 MHz(6 cores) | Windows 64 | x86_64 | 1274 | 7437 |
2702734 | HP HP ProDesk 600 G2 DMIntel Core i7-6700T2795 MHz(4 cores) | Windows 64 | x86_64 | 962 | 3580 |
2677078 | HP HP EliteDesk 800 G2 SFFIntel Core i7-67003391 MHz(4 cores) | Windows 64 | x86_64 | 985 | 3913 |
2677038 | HP HP EliteDesk 800 G2 SFFIntel Core i7-67003391 MHz(4 cores) | Windows 64 | x86_64 | 1004 | 3959 |
2592438 | GenericAMD Ryzen 7 3700X3593 MHz(8 cores) | Windows 64 | x86_64 | 1295 | 9180 |
2586962 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1296 | 9250 |
2483457 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1302 | 9250 |
2435337 | ASUS All SeriesIntel Core i7-4790K3999 MHz(4 cores) | Windows 64 | x86_64 | 1125 | 4226 |
2435180 | ASUS All SeriesIntel Core i7-4790K3999 MHz(4 cores) | Windows 64 | x86_64 | 1111 | 4226 |
2397047 | Google Pixel 3 XLQualcomm Qualcomm1766 MHz(8 cores) | Android 64 | aarch64 | 511 | 1906 |
2322772 | ASUS All SeriesIntel Core i7-4790K3999 MHz(4 cores) | Windows 64 | x86_64 | 1113 | 4279 |
2289331 | ASUS All SeriesIntel Core i7-4790K3999 MHz(4 cores) | Windows 64 | x86_64 | 1111 | 4212 |
2289218 | ASUS All SeriesIntel Core i7-4790K3997 MHz(4 cores) | Windows 64 | x86_64 | 1040 | 3398 |
2288735 | ASUS All SeriesIntel Core i7-4790K3999 MHz(4 cores) | Windows 64 | x86_64 | 1116 | 4138 |
2135674 | iPad8,9ARM2480 MHz(8 cores) | iOS 64 | aarch64 | 1112 | 4714 |
2135318 | iPad8,9ARM2480 MHz(8 cores) | iOS 64 | aarch64 | 1115 | 4648 |
2101058 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1304 | 9298 |
1937616 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1294 | 9184 |
1936449 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1288 | 9188 |
1864630 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1274 | 8461 |
1843332 | GenericAMD Ryzen 7 3800X3893 MHz(8 cores) | Windows 64 | x86_64 | 1278 | 8578 |
1171305 | Dell Inc. XPS 13 9380Intel Core i5-8265U1795 MHz(4 cores) | Windows 64 | x86_64 | 1029 | 3353 |
755561 | Microsoft Corporation Surface Laptop 3Intel Core i5-1035G71498 MHz(4 cores) | Windows 64 | x86_64 | 1229 | 4416 |
347726 | Microsoft Corporation Surface Pro 4Intel Core m3-6Y301496 MHz(2 cores) | Windows 64 | x86_64 | 569 | 1273 |
347701 | Essential PH-1Qualcomm Qualcomm1900 MHz(8 cores) | Android 64 | aarch64 | 384 | 1667 |
347688 | Microsoft Corporation Surface Pro 4Intel Core m3-6Y301496 MHz(2 cores) | Windows 64 | x86_64 | 450 | 1143 |
347643 | samsung SM-T830Qualcomm Qualcomm1900 MHz(8 cores) | Android 64 | aarch64 | 367 | 1254 |
347640 | iPhone 8 PlusApple A11 Bionic2390 MHz(6 cores) | iOS 64 | aarch64 | 935 | 2340 |
347634 | Google Pixel 3Qualcomm Qualcomm1766 MHz(8 cores) | Android 64 | aarch64 | 516 | 2102 |
347623 | MacBook Pro (15-inch Mid 2018)Intel Core i7-8850H2600 MHz(6 cores) | macOS 64 | x86_64 | 1077 | 5182 |
347598 | ASUS All SeriesIntel Core i7-4790K3997 MHz(4 cores) | Windows 64 | x86_64 | 1076 | 3707 |
347582 | ASUS All SeriesIntel Core i7-4790K3997 MHz(4 cores) | Windows 64 | x86_64 | 927 | 3718 |
292208 | Google PixelQualcomm ARMv81593 MHz(4 cores) | Android 64 | aarch64 | 319 | 928 |
292205 | Essential PH-1Qualcomm Qualcomm1900 MHz(8 cores) | Android 64 | aarch64 | 389 | 1638 |
291996 | samsung SM-T830Qualcomm Qualcomm1900 MHz(8 cores) | Android 64 | aarch64 | 360 | 1399 |
291980 | Google Pixel 3Qualcomm Qualcomm1766 MHz(8 cores) | Android 64 | aarch64 | 512 | 1931 |
291974 | iPad mini 4Apple A81500 MHz(2 cores) | iOS 64 | aarch64 | 341 | 670 |
291971 | iPhone 8 PlusApple A11 Bionic2390 MHz(6 cores) | iOS 64 | aarch64 | 926 | 2345 |
291958 | MacBook Pro (15-inch Mid 2018)Intel Core i7-8850H2600 MHz(6 cores) | macOS 64 | x86_64 | 1090 | 5192 |