Here’s what you’ll have after completing this guide:
- a Docker container running Python
- a starting point to continue with the Learn Python the Hard Way tutorial
This guide will help get you started. We'll take you through key steps, introduce you to important concept and point you to further documentation and other resources along the way. It's not intended to be a complete tutorial, and you will need to be prepared to look further into some topics on your own if necessary.
Python is a high-level general-purpose programming language that has proved itself suited to a vast range of applications. It has a design philosophy that emphasises code readability.
Before we begin
Before we create a project, please familiarise yourself with the basics of Divio Cloud. Some key topics and resources:
General overview of the Control Panel
More information about your account, project settings and more.
How to create a new Divio Cloud project
Additional detail about project creation options.
Frequently Asked Questions
You might find answers to your questions here.
More experienced developers should be aware of the material in our Developer Handbook.
Some of these guides will make more sense and be most useful once you have already dived in and are working with Divio Cloud.
Create a new project
Create a new project with the following configuration:
- Platform: Python 3.6.x
- Type: Django
- Boilerplate: Default
Then select a suitable subscription and create the project.
Why are we installing Django?
Our Django project types give you a fully-configured Python environment, so you don't have to do it yourself. You don't need to use Django itself in the project. If you prefer, you can instead build a pure Python project. Start with the No Python option, and build your project entirely from scratch as described in the Using Divio with an existing Docker image weblog article as your guide.
Set up the project locally
You will need to be aware of some key topics as we continue - refer to these articles if necessary as you go along:
Managing project servers
Understand the difference between the test and live server.
Know what you can do with your project and its settings.
How to use the Divio App
Install and configure the Divio App for local development.
Once you have installed and launched the Divio App on your computer, set up the the project you just created by clicking Setup:
This will take a few minutes to conclude. Once completed hit Divio Shell on the lower left of the Divio App.
Not working? Retrace your steps, and pay close attention to any error messages, as they will contain important information about the problem. You will also find valuable guidance in the material recommended above.
Divio Cloud uses Docker to run your projects locally. This allows you to use any programming language – be it Python, Node or PHP – locally, without configuring your operating system to support it. If you are experience issues, have a look at our troubleshooting section or our Docker guide.
Preparing for the Python tutorial
Before you can start the Learn Python the Hard Way tutorial, we need to do a few more things:
When prompted to open the source folder in a code editor: You'll find it by selecting the "folder" icon in the Divio App and opening the whole directory in your editor:
Using a shell
You will need to run commands in a command line environment. The Divio App makes this easy for you - just click on the Divio Shell button on the lower left of the app. This will create a terminal shell with all the necessary environment variables in place.
Everything should show up with green checks - if not trace your steps back to resolve it.
About shell commands
You should be familiar with basic shell commands such as
cp as they are essential items in the developer's toolbox. The Learn Python the Hard Way tutorial has a very good appendix introducing these commands.
The tutorial will ask you to run specific commands such as:
You will need to run these inside the Docker container of your project, not in your own environment on your computer. To get into the container, run the following command in the Divio Shell:
docker-compose run --rm web bash
Don't forget to
cd to into the project folder first.
Divio Cloud is built around deployment needs, and provides features such as a database, Git repository, web services and more. You don't need all this to learn plain Python. However, if building applications is your goal, our system allows you to get started in a self-contained application-oriented environment that's built around collaboration and deployment.
Git is a version control system (VCS) and tracks the history of your changes as people and teams collaborate together on a project. It is very helpful to be familiar with Git and what it does. An excellent starting point is the very popular Git tutorial on GitHub.
Start the Python tutorial
Now head over to Learn Python the Hard Way and start your journey as a Python developer.
You can skip ahead to Exercise 1: A Good First Program. From there your journey to learning Python begins.
- You can still read the first two chapters until A Good First Program. They help you to understand what's necessary to set up Python. However, there are no actions needed as Divio Cloud optimises the setup automatically for you.
- There are additional folders visible in your project. Ignore these and recommend adding a single folder where you add your exercise files. The tutorial recommends
- Learn Python the Hard Way is free until exercise 8, if you want to continue with an alternative free course, have a look at hackr.io.