Welcome back.
We've learned the true power of Python and the true power of Python comes from the community and the
fact that there are so many Python developers that we're able to leverage all these modules, all these
libraries that people have built to really do really interesting things so that we can fast track our
progress and build some really great projects really, really fast, something that we're definitely
going to do in this course.
But you may have a question.
This PI jokes that I just installed this library.
I mean, it has a version 0.5.0.
And this is called versioning in Python and in most programming languages where the first number is
usually a version where if you have bug fixes, you would go from zero to 1 to 2.
So that you update five will be a new release, maybe some added features and the last number or based
on how you look at it, the first number, the major number is usually breaking changes or major versions.
So PI jokes looks like it's fairly young, it's 0.5, but something like PI code cell that is 2.5 looks
like a mature library because they're in version 2.5.
And here's the thing.
Libraries are maintained by people, write by programmers.
We're constantly making mistakes.
There's always going to be bugs.
There's always going to be things that you can improve upon.
So these are always improving.
Versions are always increasing.
And when you start working on large projects, you start installing different packages, different modules
that perhaps only work with certain versions together.
So that maybe PI jokes 0.5 is fine.
But on a new project two years from now, I want to use Pi jokes, but the latest version of Pi jokes.
Well, what can I do in this case?
I can uninstall and let's say Pip three uninstall.
The old version of pie jokes.
So let's say pie jokes.
And maybe have a new version of pie jokes that I can install now when I do PIP three install.
PI jokes.
This is going to give me the latest version, or I could even do double equals and then give it a version
like 0.4.0.
So now if I do pip three list.
I have the older version of pie jokes.
Now, the reason I'm showing you this is that sometimes you want for your different projects, different
versions of a library, because maybe a project that you started five years ago really requires pie
jokes.
0.4 And this new project that you're starting requires pie jokes.
That's, well, let's say, upgrade it to version two.
So how do we do this?
Because right now, the way we've installed things, there's only one version of my computer that I
can use.
This is what we use for what we call virtual environments.
And it answers the question of, hey, how can we have two versions of all these packages, of all these
modules on the same machine and still have different projects using different versions?
Well, there's a tool that you can install called Pip env which allows you to use PIP.
And also this virtual amp to install packages based on each project.
So each project has its own packages.
Or if you're using Pi charm, which I usually recommend.
Especially on big projects, you have virtual environments by default.
Remember this V and folder?
Well, the end folder is a virtual environment created by Python.
As a matter of fact, let's say I want to create a new project.
Here I can create a project, let's say V or new jokes project.
And here in the dropdown you see that I have a new environment using virtual EMF.
So I can use virtual EMF, which is built into PI Charm to create a virtual environment.
You also see that I have something called Pip EMF, which I mentioned, but usually you select the virtual
environment and when you do create.
Let's say this window is fine.
When we do create.
You'll see that new jokes has its own virtual environment.
And now any library that I install in here will have its own.
Package right in here so it doesn't affect any other projects.
If I go to py v and dot cfg you see that the environment is set up with version 3.7.
This is my home and we're able to add packages.
Right in here.
And you see that?
Nope.
I don't have any pi jokes in here because this is a new project with a whole new environment.
If I create a new file, let's say.
And here we'll say new file and let's call it test, test, dot pie.
And let's say import PI jokes.
We'll say pie jokes.
Don't get joke.
What was it?
I'll just copy this.
And if I run this.
Well, I get in there.
No module named Pi jokes because I have an entire virtual environment.
It's like a separate universe.
Where I can install here, whatever I want so that it doesn't interfere with the outside world.
And usually when you're working on a project, you want to create them in virtual environments like
this.
Again, this may not seem like a big problem right now, especially if you haven't worked in the industry.
But this, trust me, is a common problem where packages are constantly being updated and you have packages
that depend on other packages that need to have certain versions.
So a virtual environment to contain all the packages that you use into your project, into this small
little environment is really, really important.
And as you start working for bigger companies, you'll notice that in your workplace they're definitely
going to be using this system.
That's a lot of talking for me.
Let's take a break and I'll see you in the next one.
Bye bye.