As you already know, whenever you want to code a new Python app, what you do is you start pancham.
Then you go to file new project, pick a folder.
For example, I have prepared this with python empty folder.
I'll just pick that.
Sometimes you may write that folder here and python will create an empty folder for you.
Either way is fine.
And then when you press on create, what happens is that Python will produce a virtual environment for
us automatically.
Then we can create Python files from here, and then we can run those Python files using port charm.
So everything happens like magic, which is fine.
The problem with that is that it's a bit of a black box for beginners.
So in this video, what I want to show you is how to create Python apps without using an ID, so that
will help you understand how things works behind the scenes and that will make you a better programmer.
So let's start.
This is with pie charm.
This folder that's just got populated with these two folders, the van folder which contains the virtual
environment.
I've already explained what virtual environments are, but I'll talk about that again in this video.
And then in this folder we also have this dot idea folder which contains configuration files about this
part term project.
So these are related to the actual project ID.
Now I also have this without pie folder in here, which is empty.
Now I want to start a new app in this folder.
So how do you do that?
Well, starting a new app implies that you need three things, so you need to create that P files.
You need a text editor to edit those plus P files.
And third, you need a python interpreter to run those dot PY files.
When we use an ID, all of that is taken care of by the ID.
But now let's see how we can get everything together to be able to code a program.
So the first thing you do out of these three is you take care of the python interpreter.
So it's a good idea to create a virtual environment and use the interpreter of that virtual environment
instead of using the interpreter you have installed globally in all your operating system.
So let's create a virtual environment first.
For that, you need to right click over that folder and go to open in terminal on Mac that could be
hidden somewhere under more services.
And then there will you'll see open new terminal or something like that.
So if you do that.
Now the terminal app here is pointing to this directory, so that's the current directory.
And here I can create a virtual environment using the command p y -3.11.
If you are on Mac or Linux, that should be Python 3.11 without spaces, but you might also want to
change the version to something else.
Whatever you have.
13.
14.
So I am on a Windows currently.
So that would be P space minus three points 11.
So please make sure to have the actual version here.
3.11 In my case then you have an MX flag.
The RM flag allows you to access Python libraries then is one of the Python libraries standard Python
libraries.
So just like we have other Python libraries which we import inside a Python script, this is also a
library, but in this case we are using it in another way.
So this library now will create a folder named End or Python likes to call it.
So as you see here, Python created this event folder.
Which you can also see inside this folder.
So that's the same directory and that same folder is what we will create now.
But in this other folder.
So if you press enter now, what will happen is that inside this folder, a vent folder will be generated.
So let's check that.
Yeah, here we go.
And if you go to the scripts folder on Mac and Linux, that should be named Bin.
So go to the bin folder on Mac or Linux scripts on Windows.
And here you should see Python.
So that's the interpreter we should use for running the files of this project.
So to create files then.
There are two ways.
You either create the files from the command line from here, if you prefer using commands, or you
can create the files using the file system.
For example, you can right click here, go to new and go to text documents and write something like
main that p y.
On Mac, you probably need to use the terminal using the command touch main dot P because on Mac is
not easy to create new text files.
Now note that even though we named this file that P on Windows, this still has a dot txt extension.
So technically this is main that p dot txt but windows is hiding that txt extension.
To fix that you want to go here.
And then go to options.
So go to file and folder options and then you want to go to view and then you want to uncheck this option.
Hide extensions for known file types apply.
Okay.
And now Windows is revealing the truth here.
So it's telling us that this does actually have a TXT extension.
So rename the file to main that spy the next you want to start coding.
So we you might use any editor that you like.
So you could use Notepad on Windows text.
Edit on Mac.
I'm just picking in a simple editor here.
Then here you can start coding like that.
Of course, as you can see, this doesn't have syntax highlighting, so you're coding in the dark,
so to say.
And this is how things were in the past when modern ideas didn't exist.
So I can save this file.
I want to run it.
Go to the terminal again.
If you close it, you should go back in here and open it again.
And then to run the file.
Now you have two options.
You can either run it with your main python interpreter, your global interpreter, or using your virtual
environment python.
So of course, the second option makes more sense.
You should use the python of your virtual environment.
That's better because it keeps this interpreter only for this project.
So if you install, for example, libraries, third party libraries for this particular python interpreter,
then these libraries will be only for this interpreter.
They will not be installed for your global python interpreter.
So to run the main that speaker file using the virtual python you do then slash on Mac or Linux.
On windows that would be a backslash.
And then on Windows you'd write scripts on Mac that would be been on Linux, it would also be Bin and
then slash again and then you access Python.
So we are accessing.
From vendors and scripts.
This python file.
And then you point to your main dot p one file.
So make sure, of course you are inside without power charm.
Otherwise this will not work.
So we are running that file using that python interpreter.
So execute that and we get.
Hello.
That's the output.
And that's how you code an app without using an I.D..
That's the manual thing of doing coding.
So when you execute an app in point charm using that triangle button, what we do is we call that particular
command.
So we start the interpreter, the virtual environment interpreter, and we interpret that file using
that interpreter, and we get the output in here.
Now, sometimes what happens is that when you open an existing project in term.
Any project.
Sometimes Pine Shire may not recognize the virtual environment immediately and you'll get probably a
message here which tells you that you should specify an interpreter, so you might click that interpreter.
Path the path that Pachachi is suggesting you or you have to go to the settings in here and then go
to projects and then go to Python.
Interpreter And then you might have to add a new interpreter by using this button here.
Add.
And sometimes pie charts may tell you that, Oh, this directory is not empty.
So in that case, you should go to this folder in your file system and delete the existing vent folder,
which is problematic, and it's causing you these messages.
And then this message will not show here anymore.
So you can press okay to create a new virtual environment if the previous one is having issues.
So that was just the tip about punch.
And thanks for following this.
I'll see you later.