|
| 1 | +# Python Setup Tips |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +There are several different ways you can install Python and set up your computing environment. Here, I am illustrating my personal preference. |
| 6 | + |
| 7 | +(I am using computers running macOS, but this workflow is similar for Linux machines and may work for other operating systems as well.) |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## 1. Download and install Miniforge |
| 12 | + |
| 13 | +Download miniforge from the GitHub repository [here](https://github.com/conda-forge/miniforge). |
| 14 | + |
| 15 | +<img src="figures/download.png" alt="download" style="zoom:33%;" /> |
| 16 | + |
| 17 | +Depending on your operating system, this should download either an `.sh` (macOS, Linux) or `.exe` file (Windows). |
| 18 | + |
| 19 | +For the `.sh` file, open your command line terminal and execute the following command |
| 20 | + |
| 21 | +```bash |
| 22 | +sh ~/Desktop/Miniforge3-MacOSX-arm64.sh |
| 23 | +``` |
| 24 | + |
| 25 | +where `Desktop/` is the folder where the Miniforge installer was downloaded to. On your computer, you may have to replace it with `Downloads/`. |
| 26 | + |
| 27 | +<img src="figures/miniforge-install.png" alt="miniforge-install" style="zoom:33%;" /> |
| 28 | + |
| 29 | +Next, step through the download instructions, confirming with "Enter". |
| 30 | + |
| 31 | +## 2. Create a new virtual environment |
| 32 | + |
| 33 | +After the installation was successfully completed, I recommend creating a new virtual environment called `dl-fundamentals`, which you can do by executing |
| 34 | + |
| 35 | +```bash |
| 36 | +conda create -n book python=3.9 |
| 37 | +``` |
| 38 | + |
| 39 | +<img src="figures/new-env.png" alt="new-env" style="zoom:33%;" /> |
| 40 | + |
| 41 | +Next, activate your new virtual environment (you have to do it every time you open a new terminal window or tab): |
| 42 | + |
| 43 | +```bash |
| 44 | +conda activate book |
| 45 | +``` |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +## Optional: styling your terminal |
| 50 | + |
| 51 | +If you want to style your terminal similar to mine so that you can see which virtual environment is active, check out the [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh) project. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +# 3. Install new Python libraries |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +To install new Python libraries, you can now use the `conda` package installer. For example, you can install [JupyterLab](https://jupyter.org/install) and [watermark](https://github.com/rasbt/watermark) as follows: |
| 60 | + |
| 61 | +```bash |
| 62 | +conda install jupyterlab watermark |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +Alternatively you can also use `pip` to install libraries instead. By default, `pip` should be linked to your new `book` conda environment: |
| 68 | + |
| 69 | +```bash |
| 70 | +pip install jupyterlab watermark |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +Any questions? Please feel free to reach out in the [Discussion Forum](https://github.com/rasbt/MachineLearning-QandAI-book/discussions). |
0 commit comments