Back to The Void

PythonAnywhere Hosting

February 16th 2022

What is PythonAnywhere?

I decided to start here, with this question, as it was something that I asked myself. I came across PythonAnywhere from a Udemy course on the Django framework. Now, to answer the question. PythonAnywhere is a hosting service that allows you to host your own python projects on the internet. There are many different companies that provide this same service such as, Heroku, DigitalOcean, AWS, etc.

PythonAnywhere differs than the others in two main ways. The first is in its database and static/media file functionality. First off, on conventional hosting services, they require you to set up an “off-site”/cloud storage for serving the media and static files that you require for your site to run smoothly. PythonAnywhere does not require this and does all the heavy lifting for you, at the same time saving you some money.

And the second big difference of PythonAnywhere compared to other companies is, PythonAnywhere does not require you to upgrade your database to a MySQL or POSTgres database. While conventional hosting services will require this change, PythonAnywhere does not and will allow you to use the default “development” sqlite3 database. While it is good practice to upgrade the database before publishing to the internet, for small projects that are for personal use, you shouldn’t have an issue.

Below are a couple short guides on PythonAnywhere:


Virtual Environments:

In order to create a new virtual environment use the bash command:
$ mkvirtualenv myvirtualenv --python=/usr/bin/python3.9 {myvirtualenvironment}

In order to deactivate a virtual environment use the bash command:
deactivate

In order to start your virtual environment use the bash command:
$ workon {myvirtualenvironment}



Pulling updated code down from GitHub and pushing to PythonAnywhere:

git pull origin -> This will pull GitHub repository into PythonAnywhere

python manage.py migrate -> This will migrate any changes you have made to your database

python manage.py collectstatic -> This will collect all static files and push them to website