Hey, Today I'll introduce you to a pretty cool service in relation to Python.
And that is Python.
Anywhere.
Python Anywhere is a service which offers you a server, a computer which runs 24 seven, and you can
use this computer to host web apps, but also to schedule tasks, to schedule Python scripts for execution
at the particular time every day.
So, for example, you can schedule a script which sends out an email at a certain time to a particular
email address, and you can also have a script perhaps, which scrapes a value from a website, some
data from websites.
You can also schedule this script to be executed at a particular time every day, and you can have the
script, store the data in text files inside the server, and later you can retrieve this data.
So Python anywhere allows you to do that and I'll show you how to do it.
So go to Python anywhere dot com and you need to sign up for an account.
You have several options there.
Both a beginner account which is free should do the job very well.
So you should create a beginner account and once you do that you should go to the login menu and to
login with your new account there.
Then you want to go to the dashboard.
That's where you have all the tools that you can use in Python anywhere.
So now I'll take you through how to use Python anywhere and its features.
So first of all, you might want to go to council's the council's menu and here you can see what is
the latest version of Python that is supported by Python anywhere.
In my case it is 3.10.
Now, if you had created your account on Python anywhere earlier on a few months ago, perhaps a year
ago, then the latest version might be 3.8 or something else.
But if you create a new account, it could be 3.10 or 3.11, depending when you created that account.
So that is something to keep in mind because we will use that version when we schedule tasks.
So just remember the newest version for now and then go to files now in files.
You will see some default files, but also files you have uploaded.
So in your case, you haven't uploaded anything yet, but I have uploaded some files before for other
projects, so you should see them here.
So these are the files that are in your computer.
So you basically have a computer here and this computer has python installed.
And in this computer you can upload files.
So this computer doesn't really have a graphical user interface and a graphical operating system as
you do on Windows or Mac or Linux or both.
You have this browser to do like basic tasks on these computers, such as uploading files, and you
can open these files as well.
To see what they contain.
So in our case, since we want to schedule.
Our main thoughts.
People file for execution, so we want to execute the script at 8 a.m. in the morning.
For example, when we want to upload the script to these files.
Now I have uploaded it before, so I'll just delete it.
And I'll play it again so that I show you how to do it.
So just click on the upload file.
Go to Main dot P.
So you need to upload all the scripts of your project and that includes main dot pie, but also send
email dot pie.
So main that I was uploaded, then upload, sent, email, dot pie and that file should be listed here
as well.
So these files are uploaded in this directory, so please copy that directory.
And then go to tusks.
Now in tasks, I have a task which is already running, so I'll cancel it.
So you should see something like this.
Now, in here, you should paste that path and then make sure you have a slash here.
Then write main dot P.
So main dot p y is a script which contains my codes.
So this is the entry point of the program.
When I execute this program, I execute main dot P right in charm.
So make sure that you point to that file in here.
But you should also write before this path.
You should write what?
Interpreter What?
Python interpreter Do you want to execute this file?
So in my case, that would be Python 3.10 and space.
So Python 3.10 space and then the path.
In your case, it should be the latest version of Python that is supported by Python anywhere.
That's why I showed you the concepts first.
So you know what versions you have there.
So what's happening here is that we're telling Python anywhere to run this command.
So to run that script with that programming language at this particular time.
So if you want to run this, let's say 2 minutes from now just to test it, then you might want to place
your 17.
In my case, the current server time is 1740.
So I want to place it like 2 minutes after that.
So the time is 42.
Now.
This should be around 1742 for now because it's not being refreshed.
So I should place it something like 1744.
Yeah.
So it's about 2 minutes from now when present create.
So this script will be executed at that time and it will be executed daily.
So I should wait a few minutes and see if I receive an email to my email address.
So it seems like I received a new email so that it is.
If you didn't receive an email, you should go to the logs which you can access in here.
So that should tell you what happened.
Now, in my case, they say that the task was completed this time.
So that was the time I schedule the task for execution.
And in your case, perhaps you have some errors which could be displayed in here.
Or sometimes you might have a message somewhere here which says that the python command was not found.
So in that case, you should go back and check if your command is correctly.
So in my case, it's Python 3.10, so I should check on consoles.
3.10 is a correct command.
So for me it's fine.
So make sure you don't have spaces in this command, but you have a space between that command and the
path.
Or you might have errors underneath here which are errors produced by the Python script.
So these are the same errors you might be getting in the pie charm command line.
So if your code has an issue, that error will be displayed here as well.
So that's something to keep in mind.
And yeah, that's how you schedule tasks for execution in Python anywhere.
So Python Anywhere has the task feature that the main feature of Python anywhere, but also it has a
web feature here.
You can host web apps.
So previously in the course we use the Heroku servers to host our stream lit app or but you can also
use Python anywhere to host certain apps.
However, Python anywhere does not work with stream apps, so you cannot host streaming apps on python
anywhere.
For a list of apps you can host, you can click on next and you can see them in here.
So Django Web two Pie Flask bottle.
These are web frameworks, Python Web frameworks used to build web apps.
So we're not going to use Python anywhere for Web apps for now.
And so what I wanted to show you was this.
That's how you can schedule tasks.
Another feature.
Also, if you go to consoles, you can open a python shell by clicking one of those versions and that
should display an interactive python shell for you on the browser where you can code.
So there you go.
That's Python 3.10 point five in my case.
And you can code here.
But of course, this is an interactive shell, so the code will not be saved in this console.
To go back to the dashboard, you can click there and go to dashboard and the console is still open
there.
So you can press there and you can access the same code you wrote earlier.
So that's about Python anywhere.
Thanks for following and I'll talk to you later.