Navigating Terminal and Running a Dash App on Mac and Windows

Navigate to your project directory in the terminal, activate the dvenv environment, run app.py with the Python command, and open the generated local URL in your browser to view your Dash app.

Run your first Dash app by navigating to the correct environment and directory using your terminal. Learn how to execute Python files locally and view real-time output in your browser using Dash’s development server.

Key Insights

  • Use the cd command with tab auto-completion to efficiently navigate from the home directory to the “data visualization curriculum main” folder in the terminal, minimizing typing errors.
  • Execute the Dash app by running python notebook-1/app.py, which launches a local development server and serves the app at a unique localhost URL viewable in your browser.
  • The Dash application runs continuously with app.run, allowing users to interact with the app in real time—initially displaying “my first dash app at Noble.”

Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.

Let's switch back to our Terminal app. Terminal on macOS, Anaconda prompt on Windows. Make sure the prompt says that you're in the dvenv environment.

You can see mine does here. If it doesn't, you can do the conda activate command. The other thing we need is to be in the right directory.

Right now we're in the home directory on Mac. It just says this home and that's the directory that your downloads and documents and pictures and desktop folder all are. On Windows, the home directory is written like this, like that.

But either way, you know, an N is your, you know, your username. We're in our home directory. What we want to do is go into our downloads directory, which is in our home directory, and from there into our data visualization curriculum main directory.

So to get into those, we are going to use the cd command for change directory and a space and then the file path from where we are right now to where we want to be. Now, you spell downloads with a capital D, but the secret sauce here is you don't have to type it all out. In fact, it's better not to.

Python for Data Science Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Because if you type it out, you'll, at some amount of the time, quite a lot for me, you'll make a mistake. So instead, type in enough to differentiate it from other folders and then press TAB. We want downloads slash on Mac OS and Linux.

And we want backslash on Windows. Then start typing in data visualization, but you can probably stop right at data unless you have a lot of files or folders in your downloads. Start with the word data and press TAB.

And now we have data visualization curriculum main. All right, once you've got that all written out, or even better, auto completed out, you can hit return or enter. And we don't get any feedback, but there wasn't a line of output like when we did echo or many lines of output like when we used conda install.

Instead, what we got is a changed prompt. It says here the current state of our terminal, which is where we have the DVENV activated, that environment. And the current directory changed from home to data visualization curriculum main.

It's a little wordier on Windows. It tells you the parent directories. But either way, it should end with data visualization curriculum main.

And if it does, then you're in the right place. Now, with our terminal in the right environment and in the right directory on our local disk, we're going to run our app.py with Python. And we use the Python command to do it.

And that Python command will execute whatever file you tell it to. So in our directory, we have a few notebook directories. If you start typing in note and hit TAB, it'll auto complete, but only until it can, only as far as it can.

Because at this point, there is a notebook one, a notebook two, and a notebook three, and notebook four. We're going to tell it notebook dash one. Then slash or backslash on Windows.

Start typing in app and hit TAB. Or type that all out. That's fine.

You be you. Be your best self. All right.

Once we've typed all that in, we can hit return or enter. And it says dash is running on some very long numeric URL. And it says debug mode on.

We'll cover what that does in a moment. But what this is actually doing is it's executing our file. It's executing all the Python in our file.

It's executing these five lines of code. But it doesn't stop executing it. Because when we do app.run, it says, okay, run the app and keep it running.

What it's doing now is it's listening for any browser that's accessing this URL, at least on our local Wi-Fi. And anybody that accesses that URL, dash says, oh, okay, here's your HTML. And it serves it up.

Let's try going to that URL. You can type it in manually, but you can also copy and paste. Easy way to do that is to select it, press the right click on it, and choose copy.

There's keyboard shortcuts and other ways to do that. Switch to your browser, paste it in, and hit return. And we get my first dash app at Noble.

We get that because that's what we told it to do. We told it to output my first dash app at Noble. All right.

Up next, we're going to cover exactly what it is that Dash is doing, what Dash is, how to change it, and then we'll dive into what we can do with Dash.

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Python

Master Python with hands-on training. Python is a popular object-oriented programming language used for data science, machine learning, and web development. 

Yelp Facebook LinkedIn YouTube Twitter Instagram