Nauč se Python > Materiály > Snake Workshop for PyLadies > Preparation > Python installation > Linux

Installing Python on Linux #

Installing Python on Linux is usually relatively simple. However, there are many types of Linux and we have the most experience with it, so these instructions are a bit longer. Don't be afraid - you will probably skip most of the sections. :)

To make sure we're installing the right version of Python, we'll refer to it as python3 in all our commands.

Installing Python 3 #

Python 3 is usually already present on Linux. To check it, run the command in the command line:

$ python3 --version

If you see “Python” and a version number (for example Python 3.6.6), and if that version is 3.6 or higher, you have it installed! Proceed to the next section, checking tkinter.

If “Python version 3.5” or lower appears, update your system and try again. If that doesn't work, send us an e-mail and we'll try to help.

If you encounter bash: python3: command not found or a similar error, install Python. The specific command depends on the distribution.

  • Fedora:
    $ sudo dnf install python3
  • Ubuntu:
    $ sudo apt-get install python3

If you are using a different distribution, maybe you already know how to install programs. If not, ask for help.

Checking Tkinter #

Some Linux distributions only include a part of the overall functionality of Python by default. Specifically, the tkinter library (which allows, for example, drawing "turtle graphics") often needs to be installed separately. To check if it is already installed, enter the command:

$ python3 -m tkinter

If a window appears, everything is okay. Close the window and proceed to installing virtualenv.

If not, install the tkinter module:

  • Fedora:

    $ sudo dnf install python3-tkinter
  • Ubuntu:

    $ sudo apt-get install python3-tk

If you are using a different distribution, you can find the correct package name on the Internet. Ask for help if you're not sure.

Installing venv #

Python has a built-in tool called venv, which we will use below. However, some Linux distributions don't install it by default. Therefore, you need to find out if you have venv and, if necessary, install an alternative.

Run the command in the command prompt:

$ python3 -m ensurepip --version

If you see a listing starting with "pip", you have a functional venv installed. You can skip the rest of this section!

However, if the message "No module named ensurepip" appears, it is necessary to install an alternative, Virtualenv.

  • Ubuntu:
    $ sudo apt-get install python3-venv

If you are using a different distribution, ask for help.

Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.