OpenCourse (talk | contribs) (Created page with "== Installation == === Linux and MacOS === On Linux and MacOS systems, Python should already be installed. You can verify this using the method in the ''''Checking installation'''<nowiki/>' chapter. If installed, you can skip to the ''''Project setup'''<nowiki/>' chapter. === Installing on Linux === If not installed, simply use your package manager to install ''''python3'.''' ==== Arch ==== On Arch-based distros (e.g. Manjaro), run the following command: sudo pacma...") |
OpenCourse (talk | contribs) No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 22: | Line 22: | ||
On Windows, navigate to the [https://python.org/download/windows Python website] (python.org) and install the latest stable build. | On Windows, navigate to the [https://python.org/download/windows Python website] (python.org) and install the latest stable build. | ||
Scroll to the bottom of this page and find ' | Scroll to the bottom of this page and find ''''Windows installer (64-bit)''''. | ||
Open the .exe file and go through the installation process. | Open the .exe file and go through the installation process. | ||
| Line 35: | Line 35: | ||
On Linux and MacOS, this is called the ''''terminal'''<nowiki/>'. | On Linux and MacOS, this is called the ''''terminal'''<nowiki/>'. | ||
On Windows, this is called the ' | On Windows, this is called the ''''command prompt'''<nowiki/>' or ''''powershell'''<nowiki/>'. | ||
=== Checking Python version === | === Checking Python version === | ||
| Line 57: | Line 57: | ||
'''> python3 --version''' | '''> python3 --version''' | ||
''zsh: command not found: python3'' | ''zsh: command not found: python3'' | ||
== Project setup == | |||
In this chapter, we will set up the project structure, and the files we will be using. | |||
=== Creating a folder === | |||
Firstly, create a new folder for the project. | |||
In this course, we will create the ''''learnpython'''<nowiki/>' folder in the ''''/home/''yourname''/coding'''<nowiki/>' folder. | |||
You can create this folder through a file manager, or through the terminal. | |||
==== Linux or MacOS command line ==== | |||
On Unix (Linux or MacOS), type the following commands. | |||
First, navigate to your documents folder: | |||
cd ~/Documents | |||
If you haven't already, create a coding folder for all your projects: | |||
mkdir coding | |||
Finally, create our project folder: | |||
mkdir learnpython | |||
==== Windows command line ==== | |||
On Windows, first navigate to the parent directory: | |||
cd C:/Users/''yourname'''''/'''Documents | |||
If you don't already have one, create a programming folder: | |||
md coding | |||
Finally, create the ''''learnpython'''<nowiki/>' folder: | |||
md learnpython | |||
=== Creating a Python file === | |||
Now we need to create a Python file. | |||
There are a few ways to do this, such as: | |||
* Using a text editor | |||
* Using the command line | |||
==== Text editor ==== | |||
To create a new Python file, open a text editor, such as VS Code, and save the file. | |||
Save the file with the ''''.py'''<nowiki/>' extension. | |||
For example, the file could be called ''''hello.py'''<nowiki/>'. | |||
Save this file in your ''''learnpython'''<nowiki/>' directory. | |||
==== Command line ==== | |||
You can also use the command line to create a Python file. | |||
If you are not still in your project folder, navigate to it using the ''''cd'''<nowiki/>' command. | |||
Then type the following: | |||
. > hello.py | |||
Replacing ''hello'' with the name of your file you want to create. | |||
== Python course == | |||
This lesson is part of the Python course. | |||
[[Python Hello World|Go to the next lesson]]. | |||
[[Intro to Python|Go to the previous lesson]]. | |||
[[Python|Go back to the course overview]]. | |||
[[Category:Python]] | |||
__FORCETOC__ | |||
Latest revision as of 11:26, 31 July 2023
Installation[edit | edit source]
Linux and MacOS[edit | edit source]
On Linux and MacOS systems, Python should already be installed.
You can verify this using the method in the 'Checking installation' chapter.
If installed, you can skip to the 'Project setup' chapter.
Installing on Linux[edit | edit source]
If not installed, simply use your package manager to install 'python3'.
Arch[edit | edit source]
On Arch-based distros (e.g. Manjaro), run the following command:
sudo pacman -Sy python3
Debian[edit | edit source]
On Debian-based distros (such as Ubuntu), type:
sudo apt install python3
Installing on Windows[edit | edit source]
On Windows, navigate to the Python website (python.org) and install the latest stable build.
Scroll to the bottom of this page and find 'Windows installer (64-bit)'.
Open the .exe file and go through the installation process.
Note: Make sure to 'add Python to system PATH'. This allows us to use Python through the terminal.
Checking installation[edit | edit source]
Terminal setup[edit | edit source]
Once you have installed Python, open a system terminal.
On Linux and MacOS, this is called the 'terminal'.
On Windows, this is called the 'command prompt' or 'powershell'.
Checking Python version[edit | edit source]
Now we need to run a command to check if Python is installed.
The result should be the name of the Python version you installed, printed to the screen.
Linux or MacOS[edit | edit source]
On Linux or MacOS, type the following command to check if Python is installed:
python3 --version
Windows[edit | edit source]
On Windows, type this command into the command prompt:
py --version
Checking Python install[edit | edit source]
If this returns a Python version, such as below, you have successfully installed Python:
> python3 --version Python 3.11.3
However, if this returns an error, like below, try reinstalling Python:
> python3 --version zsh: command not found: python3
Project setup[edit | edit source]
In this chapter, we will set up the project structure, and the files we will be using.
Creating a folder[edit | edit source]
Firstly, create a new folder for the project.
In this course, we will create the 'learnpython' folder in the '/home/yourname/coding' folder.
You can create this folder through a file manager, or through the terminal.
Linux or MacOS command line[edit | edit source]
On Unix (Linux or MacOS), type the following commands.
First, navigate to your documents folder:
cd ~/Documents
If you haven't already, create a coding folder for all your projects:
mkdir coding
Finally, create our project folder:
mkdir learnpython
Windows command line[edit | edit source]
On Windows, first navigate to the parent directory:
cd C:/Users/yourname/Documents
If you don't already have one, create a programming folder:
md coding
Finally, create the 'learnpython' folder:
md learnpython
Creating a Python file[edit | edit source]
Now we need to create a Python file.
There are a few ways to do this, such as:
- Using a text editor
- Using the command line
Text editor[edit | edit source]
To create a new Python file, open a text editor, such as VS Code, and save the file.
Save the file with the '.py' extension.
For example, the file could be called 'hello.py'.
Save this file in your 'learnpython' directory.
Command line[edit | edit source]
You can also use the command line to create a Python file.
If you are not still in your project folder, navigate to it using the 'cd' command.
Then type the following:
. > hello.py
Replacing hello with the name of your file you want to create.
Python course[edit | edit source]
This lesson is part of the Python course.