Python for .NET Developers Transcripts
Chapter: The Python Language
Lecture: Creating the Python project

Login or purchase this course to watch this video and the rest of the course contents.
0:00 All right, time for some Python. You've seen the C# code over here and we haven't looked at most of it but you can imagine the web part
0:09 the website that we're going to build in Python the testing parts, the testing we're going to build. We're not starting from any code at all
0:16 when it comes to Python. We're going to write every single bit of it during this course, which I think really helps you internalize it
0:23 and see how it's put together in the whole flow. So what we're going to do is we're going to create a new project, we already started with our C# code
0:30 with our solution and our projects and our project structure and all that over here so we're going to do that right now for Python.
0:37 With Python, I could just create a file here and start working on a directory and then put a file in it potentially.
0:42 There's not really a project structure I have to create. But I want to use something called PyCharm. PyCharm, which I already introduced earlier
0:50 is a really excellent editor. If you don't want to use PyCharm then also VS Code with a Python plugin is super good similar setup here anyway.
0:59 For Python, what we're going to do is you want to create something called a virtual environment. When you install Python, it gets installed
1:05 into your system and it has some packages and libraries set up and some configuration. But if you want true isolation
1:12 so this project has its own set of files and is completely isolated from all the other things that might have happened on your operating system
1:20 what you do is you create this thing called a virtual environment. So we're going to create a virtual environment and then load this into PyCharm.
1:26 So let's just jump into the terminal over here on it's a little extension I have called GoToShell and you see, there's nothing here yet.
1:35 What we're going to do is we're going to create what's called this virtual environment and the way we're going to do that is we're going to
1:40 type Python3 here. On Windows, you can, depending on how you install it you may or may not be able to type Python3
1:48 so just do Python but here I'm going to do Python3 -m to run a module. The module is called venv for virtual environment
1:55 and the folder we're going to create is also venv. Now we have this folder here and this is basically a copy of Python and the entire Python run time.
2:05 Sort of symlinks back, but basically it's a copy of Python think of it that way, at least conceptually. Now in order to use it, we have to activate it.
2:13 So we can say source venv/bin/activate. And notice our prompt changes. On Windows, don't have this course source concept
2:22 you say venv\scripts\activate.bat I don't know why those have to be different, but they are. Okay so now we have this as our active Python here.
2:36 We can load up this project into PyCharm and when we install stuff like libraries we want to use think NuGet packages and other stuff like that
2:44 what we're going to configure is this little local version this local version of Python, so whatever we do it's absolutely exactly as we want it
2:53 and it's not affected by the other stuff. Not technically necessary but a very good practice so we're doing it right at the start of this project.


Talk Python's Mastodon Michael Kennedy's Mastodon