Reactive Web Dashboards with Shiny Transcripts
Chapter: Hello Shiny
Lecture: Setting up the environment
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Okay, so Shiny lets you use any web editor that you like, but we'd recommend using something like VS Code for the purposes of this course,
0:09
mostly because we have a pretty good VS Code extension for Shiny, which gives you some auto-completion and a nice viewer.
0:17
So let's go ahead and install that right now. So you go to the extension tab on VS Code or if you're using cursor, which is a fork of VS Code,
0:25
and just search for Shiny for Python, and we're going to go ahead and install this one. Once that's installed, you'll be able to run a Shiny app.
0:36
The next thing we need to do is actually install Shiny, and Shiny is on PyPy, and I can recommend using pip for this.
0:45
But before I actually go ahead and install it, I'm going to create a virtual environment.
0:51
I think most people these days tend to use virtual environments, but if you don't use one,
0:57
it's really important, especially when developing web applications, because it makes it easier to deploy your application to
1:04
a hosting service and have everything be installed properly. Again, you can use whatever environment manager you like.
1:10
I'm going to use the VM one that's built into Python. Then I need to select my interpreter.
1:24
Now when I do that, I see this little.vn thing at the beginning of VS Code, and that tells me that when I'm installing,
1:32
I'm installing into that virtual environment. The next thing we do is just type ""Pip install Shiny"",
1:40
and hopefully this will give me a nice little Shiny app. We have Shiny installed, and now we want to try to figure out what to do with Shiny.
1:51
One of the best things you can do to get some ideas or see what Shiny can do is to go to the website.
1:56
In particular, I want to start with this little components tab, and this has a few different things that are worth just being aware of.
2:04
One is it has the components. These are the buttons and links and inputs that are available in Shiny. Each of these has,
2:11
you can click through to see some examples. It lets you interact with the widgets to see what they do. There is also a templates gallery,
2:20
and this templates gallery includes full-featured Shiny applications. There's some basic ones, some nice dashboards.
2:28
If you click through to one of these dashboards, it gives you this little shell command that will just basically clone this code locally.
2:39
Down here, you can see a running version of the application to give you an idea of what that actually is going to do. Shiny has two syntaxes.
2:47
One is Express, which is what we're going to be using in this course, and the other one is Core.
2:50
For the most part, whenever you see a little tab set like this, just make sure that it's clicked on Express, and that'll give you the example
2:58
and everything that's appropriate for this class.