Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Part 1
Lecture: PyCharm Demo
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
You've seen how to create a new pyramid web application on the command line and we're going to do a little bit of follow up of that here,
0:08
but in this particular video, we're going to focus on how to work with PyCharm. Namely, PyCharm professional;
0:15
let's switch over to PyCharm and see what we can do. So the first thing I want to focus on is, let's just see
0:22
how that project we created with the command line could be opened in PyCharm. So if I come over here, you can see here's the web app
0:30
and remember, if you look over here, into this folder that there's actually this invisible, hidden .env folder,
0:40
so with all that in place, if I drop this on to PyCharm, it's going to open it, on Linux you have to say file open directory
0:50
and then just find that directory, we can open it up and it's already got it; now notice, there's a couple of things,
0:55
first it's doing some indexing the very first time it's seen this virtual environment
0:58
so it can help, after this it should have that cashed and be much quicker. So notice, it's already gotten a little pyramid logo up here,
1:06
and a play button, that's because it actually discovered this was a pyramid web app and it's created what's called a run configuration that can run it,
1:14
that's because this is PyCharm professional, if you don't have the professional edition, this is not going to work;
1:21
you can still go and create one and there's a video at the end of this chapter
1:24
showing you how to do it, but it's not going to automatically find this for you.
1:28
The other thing to notice is it's already found that virtual environment so if you go down here, notice if I open up the terminal
1:35
and I ask like which Python, you can see it's already using that one that's in here. When I run this, it's also using that one, you can see here.
1:45
There's the two things, we click this, boom it's working again. So that's how to take the existing one
1:51
that we created outside in the command line and get it running here. Let's start from scratch.
1:57
So let's take a step back and say we want to create a brand new project in PyCharm, remember, this only works in professional,
2:04
see the other video if you are using community edition. Okay, so we'll create a new project and down here we will pick pyramid
2:11
and it's got an old out of date interpreter, so that's all well and good, let's tell it we want to put it into this project area on our desktop.
2:18
So I'm going to go here and then we'll give it something not just that we're going to say this is going to be my_pycharm_app or something like this
2:26
we're going to pick chamelon, these are hidden you might need to push them down, starter is the scaffold that we\re looking for,
2:35
chameleon is the template language and this is all perfect; this virtual environment is not great, so let's go and create one,
2:40
so we'll say create a virtual environment and where do you want to create it, we're going to create it here.
2:47
And I'm not going to call it project area, I'm going to call let's say /my_pycharm_env, do it like this,
3:02
now this is super important, don't forget to turn this off for Python 2 you want Python 3, really important.
3:08
So, we'll pick Python 3, we'll hit okay, it's going to create a new one you can see it's installing all the things that we need,
3:15
okay, everything is ready to roll, it's pointing out hey notice the pyramid is not installed into this virtual environment yet,
3:21
of course not, but it's going to install of course, so we hit create, now it's going to go ahead and install pyramid just stand alone for us
3:31
and once it's done indexing these files which of course is going to cash again afterwards, it says this project is not installed for development,
3:39
so you should run setup.py develop, so let's just click that. Notice it also has package requirements are missing
3:47
but by running the development setup it's going to basically hit both of those issues and take care of them.
3:52
Boom, everything is set up, the project is set up, the dependencies are installed, the run configuration is set
3:59
the run configuration is set to run, that virtual environment again if we look in the terminal down here,
4:04
there's our virtual environment we had it create if we hit run, it's running that virtual environment and there it is once again up and running.
4:12
In this case, it's not generated by cookiecutter it's generated by PyCharm. So, using PyCharm is a pretty nice way to get started
4:20
when I first started working with pyramid and was newer to Python I would use this a lot, now I find myself using the command line version
4:28
and then opening it like I showed you right at the beginning of this video in PyCharm, whatever makes you happy, they're all basically equivalent.
4:35
All right, now our app is created, up and running, we're ready to start adding features to it.