Python Tutorial - Installation

Jinku Hu Jan 03, 2023
  1. Python 3 Installation
  2. Virtual Environment Installation
Python Tutorial - Installation

The first step to learn any programming language is actually not Hello World, but the installation of the language package.

Python 3 Installation

Python 3 on Windows

Firstly, go to Python official website download page https://www.python.org/downloads/ to download the latest version of Windows - Python 3.6.4 as it is in January 2018.

The installation directory of Python is by default embedded with the Python version number, e.g. The latest version Python 3.6.4 will be installed at C:\Python36\. You could install multiple Python versions installed on your PC without any conflicts. But it also means that you need to specify the Python version number every time you start python if you have multiple Python versions. For example, put C:\Python36\ to the system PATH variables. Or for simplicity, you could use the bash script below to modify PATH.

set PATH=C:\Python36;%PATH%
Warning
Be aware of that PATH=C:\Ptyon36 should be ahead of %PATH%, otherwise, the system will call the Python in the existing system PATH has already contained other Python version’s full path.

Python 2 on Windows

The installation process is similar to the above process with the difference that you should download latest Python 2 version, that is, Python 2.7.14 as it is in January 2018.

Virtual Environment Installation

A virtual environment is a Python environment in which you can install separate interpreter, libraries, and scripts. So this virtual environment is isolated from other virtual environments and any change (installation and deletion) will not affect this virtual environment.

Python virtual environment can be created by using the following tools:

  1. venv which is present by default when you install Python version 3.3 and later and it installs pip and setuptools in virtual environment in Python version 3.4 and later.
  2. virtualenv is also a tool to create Python virtual environment. Python version 2.6+ and 3.3+ are supported by virtualenv. When you are using virtualenv for creating virtual environment, pip, setuptools and wheels will be installed by default in our virtual environment.

In this section, virtualenv will be used to create an isolated Python virtual environment and then packages will be installed into the corresponding virtual environment:

Below are the steps you should follow,

  • Install distribute and pip

distribute download address: https://pypi.python.org/pypi/distribute/
pip download link: https://bootstrap.pypa.io/get-pip.py

  • Run command prompt as administrator and navigate to the folder where you have downloaded distribute and pip.
  • Now run the following commands for the installation of distribute and pip:
   C:\> cd Users\HP\AppData\Local\Programs\Python\Python36-32
   C:\Users\HP\AppData\Local\Programs\Python\Python36-32> Python distribute_setup.py
   C:\Users\HP\AppData\Local\Programs\Python\Python36-32> Python get-pip.py
  • Install virtualenv:
pip install virtualenv
Author: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook