Back to the video

Installing Wagtail using venv

Transcript

From Wagtail CMS 2020. Published January 19, 2020.

Watch the video Markdown version 870 words · auto-generated · en

Summary

The speaker demonstrates installing Wagtail 2.7 in a Python virtual environment using Python 3.7.2. They create a project directory and virtual environment, activate it, install Wagtail, and use `pip show` and `pip freeze` to inspect the installed packages. They then create the Wagtail project in the current directory, install its requirements, run the development server, apply the database migrations with `python manage.py migrate`, and confirm the site loads at localhost:8000. The speaker also explains that separate virtual environments can use different Wagtail versions without conflicts and shows that `deactivate` exits the environment.

Transcript

Automatically transcribed, so expect mistakes in names and technical terms. Filler words are removed.

0:00 Creating the Virtual Environment

Alright, we are going to install Wagtail using Venv, VNV. So I already have Python running, and you can see I'm running Python 3. 7. 2. So I'm going to do Python-m venv And then the name of whatever virtual environment I want to call. I'm gonna call this Rocketman Venv. Actually, what I'm going to do is create a new directory first. So let's cancel that and let's do mkdiar. Rocketman. C D Rocketman and you can see my working directory here. So I'm in users, Caleb Tallinn, Websites Rocketman, and now I'm going to do Python-m venv rocketman venv. The name is not really important, it's just your virtual environment. So I'm going to call it rocketman

0:46 Activating and Verifying venv

venv, and we're going to see it's going to create a new directory for me here. So let's do an ls-la, and we can see that there is a folder in here called rocketman venv. Right in there To get into this thing, all we have to do is type source, rockamanvenv, bin, activate, which if this is your first time that's going to look really weird, but you know, after a little while you get used to it. and I am now inside of this virtual environment. And you can see that cause it says Rocketman Venv in brackets to the left of my user So now at this point I can do pip V. We can see I'm using pip 18. 1. It's coming from My virtual environment, that's the folder here, that's the directory, Python 3. 7. So that all looks good. Let's go ahead and install Wagtail now. So pip

1:31 Installing Wagtail

install Wagtail. Alright, so Wagtail has been installed. I can now do pip show Wagtail. It shows me that I'm using Wagtail version 2. 7. Right there. I can also do pip freeze to see all of my packages that are installed in this virtual environment. So I've got BeautifulSoup, Certify, Django, Django TreeBeard, HML5lib. Pillow, requests, 6, URL lib, wagtail, willow, all sorts of stuff. So that's what is installed in my virtual environment. My computer does not have access to that unless I'm inside of that virtual environment. Now I'm able to say that this project is going to run Wagtail 2. 7, and in another virtual environment I can say, hey, use Wagtail 2. 4. Use an older version of Wagtail, use Wagtail 1.

2:18 Creating the Wagtail Project

13 if we wanted to. And these will never conflict with each other, which is really, really nice. So now what we need to do is Wagtail, Start, MySite. And that's going to create a website called my site. I don't want it to be called my site. I'm going to be c making a website called Rocketman. So I'm going to do Wegtail Start Rocketman. That's going to create a new folder called Rocketman, but I don't want it to do that. I want it to create a new project, a new Wagtail website in the directory that I'm in. I'm already in a directory called Rocketman. I've got a virtual env in here and I want to create this new project in this directory. So let's go ahead and do that. You can see that that was very fast. ls -la and we now have Docker file, home folder, managed. py, requirements. txt , Rocketman folder, that's where our settings and static files and templates are going to go.

3:06 Running the Development Server

We've got a search app and we've got our virtual environment So now we can do pip install dash r requirements dot txt and All of that, it looks like it's already been satisfied to some degree. And now to run our server, we just type python manage. py run server 0. 0. 08000 And it should say this. You should see this alarming red text saying you have 89 unapplied migrations. And if we were to open up our browser. And head on over to localhost port 8000. We're going to see this error. That's actually a good thing. That means your website is up and running. So I just canceled my server there with

3:52 Applying Migrations and Deactivating venv

control C. That 'll just cancel your server so it doesn't run anymore. And next we need to provision our database because if we Skip back over to where this error is showing up on localhost 8000. We're gonna see it says no such table wagtail core site Well a table is a database term. This is looking for a database that's set up in a specific way to get started, and it's not set up that way. So let's go ahead and set that up the proper way. So let's do Python manage. py migrate. And we'll see this is going to apply all these different files. And then If we rerun our server with Python manage. py run server 00008000, let's go back here and refresh our page. Voila! We have Wagtail installed using

VNV or Venv. And then to get out of your virtual environment, you just have to type the word deactivate. You can see that down here. Sorry, that's at the bottom. But yeah, you just type the word deactivate and that Rocketman Venv seems to go away.