Step-by-Step Guide: Installing Anaconda on Mac and Windows and Writing a Simple “Hello Py” Project in Jupyter Notebook
In this article, I will walk you through the process of installing Anaconda on both Mac and Windows, setting up your environment, and writing a simple “Hello Py” project in a Jupyter Notebook.
Anaconda is a powerful distribution that simplifies package management and deployment in Python, making it easier to work with data science, machine learning, and other scientific computing projects.
You can connect with me on LinkedIn and join my professional network.
Get notified when I publish new articles. I never share your email address and your subscription is only used to send you a notification when I publish new articles.
Step 1. Download and Install Anaconda
For Mac: Download Anaconda:
- Visit the Anaconda website and click on the “Download” button.
- Select the macOS version (usually the 64-bit Graphical Installer) and download the installer.
Install Anaconda:
- Once the download is complete, open the
.pkg
file. - Follow the prompts in the installation wizard. You can keep the default settings or customize the installation location if needed.
- During installation, you may be prompted to install
Anaconda3
into your PATH environment. It's recommended to allow this if it asks you.
Verify Installation:
- Open the Terminal application.
- Type
conda list
and press Enter. This command lists all installed packages and confirms that Anaconda is installed correctly.
For Windows: Download Anaconda:
- Visit the Anaconda website and click on the “Download” button.
- Select the Windows version (usually the 64-bit Graphical Installer) and download the installer.
Install Anaconda:
- Once the download is complete, run the
.exe
installer. - Follow the prompts in the installation wizard. You can choose to install Anaconda for “Just Me” or “All Users,” depending on your preferences.
- It’s recommended to keep the default installation path.
- During installation, check the option to “Add Anaconda to my PATH environment variable” and “Register Anaconda as my default Python.” This ensures that Anaconda is properly integrated with your system.
Verify Installation:
- Open the Command Prompt.
- Type
conda list
and press Enter. This command will list all installed packages, confirming that Anaconda is installed correctly.
Step 2. Launch Anaconda Navigator
Anaconda Navigator is a graphical user interface that allows you to launch applications, manage environments, and install packages.
Open Anaconda Navigator:
- On Mac, open Spotlight by pressing
Cmd + Space
, type "Anaconda Navigator," and press Enter. - On Windows, search for “Anaconda Navigator” in the Start menu and click on it.
Launch Jupyter Notebook:
I put red boxes around JupyterLab and Jupyter Notebook. You will use one of these to write your Python code. For new learners, I suggest starting out with Jupyter Notebook and as your projects become more complex, Jupyter Lab is the way to go.
JupyterLab and Jupyter Notebook are both interactive environments for writing and executing code, particularly in Python, but they differ in terms of features and user experience. Jupyter Notebook offers a straightforward interface, where you can create and run code cells in a linear, notebook-style document. It’s widely used for data analysis, educational purposes, and sharing computational work. On the other hand, JupyterLab is a more advanced, flexible, and integrated environment that extends the functionality of Jupyter Notebook. It provides a more powerful interface with a modular design, allowing users to open multiple notebooks, terminals, text editors, and output views side by side in a single workspace. This makes JupyterLab ideal for more complex workflows and projects that require a combination of different tools and resources within one interface.
Step 3. Create a New Jupyter Notebook
Start a New Notebook:
- In the screenshot above, I had created a directory called Anaconda-Jupyter-Notebooks off the root drive to store all of my notebooks. When I opened Jupyter Notebook, I simply navigated to this directory before moving to the next step.
- When you open Jupyter Notebook, a terminal window will open in the background for you. Do not close this while you are working in Anaconda/Jupyter Notebook.
- Select “Python 3” from the dropdown menu. This will open a new notebook where you can start writing your Python code.
- Then, you will see a new and untitled Jupyter Notebook as shown in the screenshot below.
Write the “Hello Py” Project:
- In the first cell of your new notebook, type the following code:
print("Hello Py!")
- To run the code, either press
Shift + Enter
or click on the “Run” button in the toolbar. The output “Hello Py!” should appear directly below the cell.
4. Save and Close Your Notebook
Save the Notebook:
- To save your work, click on “File” in the top menu and select “Save As.” Name your notebook (e.g., “Hello_Py.ipynb”) and save it to your desired location.
Close the Notebook:
- Once you’re done, you can close the notebook by clicking on the “File” menu and selecting “Close and Halt.” This will stop the notebook from running.
Exit Jupyter Notebook:
- To exit Jupyter Notebook, click “Quit” on the Jupyter dashboard (the main page where all your notebooks are listed).
- Close the browser tab and the Terminal/Command Prompt window that opened when you launched Jupyter Notebook.
Step 5. (Optional) Install Additional Packages
If you need additional Python packages for your projects, you can easily install them using conda
or pip
.
- Using
conda
: - Open the Terminal (Mac) or Command Prompt (Windows).
- Type
conda install package_name
(replacepackage_name
with the name of the package you need) and press Enter. - Using
pip
: - If you prefer using
pip
, typepip install package_name
in the Terminal or Command Prompt.
Conclusion
By following these steps, you’ve successfully installed Anaconda on your Mac or Windows machine, launched a Jupyter Notebook, and created a simple “Hello Py” project. Anaconda and Jupyter Notebook together provide a powerful platform for your Python programming needs, making it easy to manage packages, environments, and projects in one place.
You can connect with me on LinkedIn and join my professional network.
As your next step, go to my Python for Newbs getting started guide and learn the fundamentals so you can be a real python programmer.