Your first Python program: Hello, Anaconda!#

Back to Getting Started

This tutorial will take you through a short programming exercise, using Navigator and then a command line interface (CLI).

Launching development environment applications from Navigator#

We will first go through some short exercises using Anaconda Navigator to launch two different integrated development environments (IDEs), Spyder and Jupyter Notebook.

Open Navigator#

Choose the instructions for your operating system:

  • Windows - From the Start menu, click the Anaconda Navigator desktop app.

  • mcOS - Open Launchpad, then click the Anaconda-Navigator icon.

  • Linux - Open a terminal window and use the command anaconda-navigator.

Run Python in Spyder#

Tip

More of a visual learner? Follow along with Create a simple Python program in Spyder on Anaconda Learning instead!

  1. On Navigator’s Home tab, in the applications pane on the right, launch the Spyder IDE from its tile.

    Note

    If Spyder is not installed in your current environment, click Install to install it.

  2. Spyder opens with a temp.py file open on the left.

  3. In temp.py, delete any placeholder text and add print("Hello, Anaconda") to line 1.

  4. In the top menu, click File > Save As and name your new program hello.py.

  5. Run your new program by clicking the triangle Run button.

  6. Click Run in the run settings dialog that appears.

  7. You can see your program’s output in the bottom right console pane.

  8. Close Spyder.

Run Python in a Jupyter Notebook#

Tip

More of a visual learner? Watch our short training videos on Jupyter Notebook and JupyterLab on Anaconda Learning instead!

  1. On Navigator’s Home tab, in the applications pane on the right, launch Jupyter Notebook from its tile.

    Note

    If Jupyter Notebook is not installed in your current environment, click Install to install it.

  2. Jupyter Notebook launches in a new browser window (or a new tab), showing the Notebook Dashboard.

  3. Click the New dropdown.

  4. Create a new notebook with the Python version you installed.

  5. Click your new notebook’s “Untitled” name to rename it. You can name it to whatever you’d like, but for this example we’ll use “MyFirstAnacondaNotebook”.

  6. In the first line of the Notebook, add print("Hello, Anaconda").

  7. Save your notebook.

  8. Run your new program by clicking Run or selecting Cell > Run All from the top menu.

  9. Close the browser tab containing Jupyter Notebook.

Close Navigator#

From here, you can close Navigator and move on to the conda CLI tutorial below:

  • Windows - Go to File > Quit in the Navigator File menu.

  • macOS - Go to Anaconda Navigator > Quit Anaconda-Navigator in the top menu.

Write a Python program using a CLI#

Open your CLI#

There are many command line interface (CLI) options available to you. Anaconda recommends that Windows users use Anaconda Prompt, while macOS and Linux users are welcome to use whatever CLI they are comfortable with.

Note

macOS and Linux users - If you aren’t seeing (base) in your chosen CLI, you need to either initialize conda or activate your base environment. See either the macOS or Linux install instructions for more information.

Start Python#

In your CLI, type python and press Enter or return.

A >>> appears in your CLI and means you are in the Python interpreter, which allows you to run simple scripts right from the command line.

Write a Python program#

At the >>>, type print("Hello, Anaconda!") and press Enter or return.

When you press Enter or return, your program runs. The words “Hello, Anaconda!” print to the screen. You’re programming in Python!

Exit Python#

  • Windows - Press CTRL-Z and press Enter.

  • macOS or Linux - Type exit() and press Enter or return.

Optional: Launch Spyder or Jupyter Notebook from the command line#

  • In your CLI, type spyder and press Enter or return. Spyder opens just like it does when launched from Anaconda Navigator.

  • In your CLI, type jupyter-notebook and press Enter or return. Jupyter Notebook opens in a tab in your browser.

You can run the same exercises in Run Python in Spyder and Run Python in a Jupyter Notebook after opening Spyder and Jupyter Notebook from your CLI.