Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: Setup and tools
Lecture: Installing Eve and its dependencies
0:01 Installing Eve is a simple task.
0:03 As with basically every other Python tool,
0:05 you really want to install it into a virtual environment.
0:08 A virtual environment is a Python environment
0:11 where the Python interpreter, libraries and scripts installed into it
0:15 are isolated from those installed in other virtual environments
0:18 and any libraries installed in a system Python,
0:21 like the one which is installed as part of your operating system.
0:25 So let's install Eve.
0:27 As you can see, I'm using a Mac here,
0:29 if you are on Windows, don't worry,
0:31 everything you see me doing during this course will also work on Windows
0:35 just make sure that you are using backslashes
0:37 whereas I'm typing forward slashes in the file paths,
0:43 folder names, stuff like that.
0:45 The first thing we want to do is make sure
0:47 that Python is actually installed on our system and ready to work.
0:50 So let's ask which Python 3, there it is, so we can use it.
0:56 If you wanted to use Python 2,
0:58 of course, we just have to go with Python.
1:03 We now want to create our vital environment
1:05 and within this virtual environment,
1:07 we will install Eve and all of its dependencies,
1:10 so Eve will be isolated from other Python installations in our system.
1:16 When it comes to virtual environments in Python
1:19 we are left with two options really,
1:21 one is called virtual env, you probably know about it already
1:25 because it's been around since forever,
1:27 it is very nice because it works equally well on Python 2 and Python 3,
1:32 so if you are working on Python 2, you probably want to use it.
1:36 You actually have to install it because it doesn't come with Python
1:40 but since we are working on Python 3,
1:42 we want to use the new method which comes built in with the Python itself
1:48 so we are going with Python 3 - m venv
1:53 and then it wants a path, virtual envs/eve-course,
1:59 so let's review this command here.
2:02 Python 3 is, of course, the interpreter,
2:05 - m is an option which is basically instructing Python
2:08 to execute the following module here as a script and then we have a path,
2:15 if the path doesn't exist on your system, it will be created for you.
2:19 As you can see, I'm using a root folder for all my virtual environments
2:23 and then I'm building an Eve course folder within the root folder.
2:28 Let's execute it— bam,
2:33 now let's take a look at our system,
2:36 as you can see, I have a new folder here virtual env,
2:39 and if I look at it there is my Eve course within it.
2:47 If we inspect the Eve course, we see that the number of folders on the file
2:51 we don't really care about what is being stored within this folder,
2:56 we just need to know that this is where all of our packages will be installed
3:02 and where the activation and the activation scripts
3:05 for our virtual environment are also stored.
3:08 How do we activate this virtual environment actually?
3:11 Well, I just use the source command
3:19 and then I go and use the activate script
3:24 as you can see, the prompt has changed
3:27 and it is telling me that now we are inside our virtual environment
3:31 and since we are inside a virtual environment
3:35 and every single virtual environment activated with Python
3:38 comes with the installation tools
3:41 we can already use pip
3:43 and ask for what's installed in our environment right now,
3:47 and of course, there is nothing because we just created this environment.
3:51 Now I can go and finally install Eve with pip install eve.
3:57 When I hit return here, it will go online, look up for Eve
4:01 and then install Eve itself and all of its dependencies.
4:09 There it goes.
4:11 As you can see it's collecting all the info
4:13 and then it is running all the setups,
4:16 scrapes for each of the dependencies,
4:20 and finally we get a very nice message here
4:22 which is telling us all the dependencies
4:25 with their versions which have been installed.
4:27 Now, if I try pip freeze again
4:32 I see that I have all of my dependencies ready to work
4:36 and in fact, if I run Python, I get Python 3.6.
4:41 I can for example import Eve— it works.
4:47 And how do I deactivate my virtual environment?
4:50 Well, it is very easy, I just need to use the deactivate command.
4:55 As you can see, the prompt has changed back again
4:58 to no virtual environment name
5:01 and in fact, if I try to use pip here, it doesn't even work
5:06 because it's not there, it only comes with virtual environment
5:11 or I have to install it on my system Python,
5:15 I can always go back to my
5:21 virtual environment and again, ready to work.