1. Linux

Do not upgrade pip using the sudo pip install --upgrade pip command because pip should be installed using the debian package manager. Perform an uninstall using the sudo pip uninstall pip command to undo.

1.1. Python 2 Installation

  • Enter the following commands at a Command Line.

    sudo apt-get install python
    sudo apt-get install python-pip

1.2. Python 3 Installation

  • Enter the following commands at a Command Line.

    sudo apt-get install python3
    sudo apt-get install python3-pip

1.3. Information

  • Enter the following commands at a Command Line.

    which python python2 python3
    ls -al /usr/bin/python*
    python  --version       # Debian 8: 2.7.9       Debian 9: 2.7.13        Debian 10: 2.7.16
    python2 --version       # Debian 8: 2.7.9       Debian 9: 2.7.13        Debian 10: 2.7.16
    python3 --version       # Debian 8: 3.4.2       Debian 9: 3.5.3         Debian 10: 3.7.3
    
    which pip pip2 pip3
    ls -al /usr/bin/pip*
    pip  --version  # Debian 8: 1.5.6 (python 2.7)  Debian 9: 9.0.1 (python 2.7)    Debian 10: 9.0.1 (python 2.7)
    pip2 --version  # Debian 8: 1.5.6 (python 2.7)  Debian 9: 9.0.1 (python 2.7)    Debian 10: 9.0.1 (python 2.7)
    pip3 --version  # Debian 8: 1.5.6 (python 3.4)  Debian 9: 9.0.1 (python 3.5)    Debian 10: 9.0.1 (python 3.7)

1.4. Configuration

Ubuntu 18.04 and later has only python3 installed. There is no python command anymore, only a python3 command. Because of that, the following configuration is questionable and should probably be skipped.

On Debian 8 the python command links to Python 2.
On Debian 9 the python command links to Python 2.
On Debian 10 the python command links to Python 2.
On Ubuntu 17.04 the python command links to Python 2.
On Ubuntu 18.04 there is only a python3 command.

After this configuration the python command links to Python 3.

  • Enter the following commands at a Command Line.

    ls -al /usr/bin/python*
    sudo rm /usr/bin/python
    sudo ln -s python3.4 /usr/bin/python    # Debian 8
    sudo ln -s python3.5 /usr/bin/python    # Debian 9
    sudo ln -s python3.7 /usr/bin/python    # Debian 10
    ls -al /usr/bin/python*
    # Change python to python2 in /usr/bin/pip2 file.
    sudo sed -i -e s/python$/python2/g /usr/bin/pip2
    
    python  --version               # Debian 8: 3.4.2               Debian 9: 3.5.3                 Debian 10: 3.7.3
    python2 --version               # Debian 8: 2.7.9               Debian 9: 2.7.13                Debian 10: 2.7.16
    python3 --version               # Debian 8: 3.4.2               Debian 9: 3.5.3                 Debian 10: 3.7.3
    pip  --version                  # Debian 8: 1.5.6 (python 3.4)  Debian 9: 9.0.1 (python 3.5)    Debian 10: ?.?.? (python 3.7)
    pip2 --version                  # Debian 8: 1.5.6 (python 2.7)  Debian 9: 9.0.1 (python 2.7)    Debian 10: 9.0.1 (python 3.5)
    pip3 --version                  # Debian 8: 1.5.6 (python 3.4)  Debian 9: 9.0.1 (python 3.5)    Debian 10: 9.0.1 (python 3.7)

1.5. Compilation

  • Login as root on smru-efw-mrm.

# tbhf-anc-mrm: scp -p /home/Other/Tmp/mail.py root@10.10.1.170:/tmp
# tbhf-anc-mrm: scp -p /home/Other/Tmp/mailfile.py root@10.10.1.170:/tmp

# cp -a /tmp/mail.py /tmp/mail.py.orig
# Replace _subtype='text' by _subtype='plain' in the /tmp/mail.py file.
# diff /tmp/mail.py.orig /tmp/mail.py

+

219c219
< def buildMIMEMessage(body, subject, to_addr, from_addr='', _subtype='text', attachment='', multipart_type=None):
---
> def buildMIMEMessage(body, subject, to_addr, from_addr='', _subtype='plain', attachment='', multipart_type=None):

+

python
import py_compile
py_compile.compile('/tmp/mail.py')
py_compile.compile('/tmp/mailfile.py')
quit()

+

mailfile -a /tmp/diff2.txt -d -f root@smru-efw-mrm -s "Test Message 1" -t douwe@shoklo-unit.com -v "HELLO"
cp -a /usr/lib/python2.7/site-packages/endian/core/mail.pyc /usr/lib/python2.7/site-packages/endian/core/mail.pyc.orig
cp -a /usr/lib/python2.7/site-packages/endian/core/mailfile.pyc /usr/lib/python2.7/site-packages/endian/core/mailfile.pyc.orig
vdir /usr/lib/python2.7/site-packages/endian/core/mail* /tmp/mail*.pyc
cp -a /tmp/mail.py /usr/lib/python2.7/site-packages/endian/core
mailfile -a /tmp/diff2.txt -d -f root@smru-efw-mrm -s "Test Message 2" -t douwe@shoklo-unit.com -v "HELLO"

# Restore
cp -a /usr/lib/python2.7/site-packages/endian/core/mail.pyc.orig /usr/lib/python2.7/site-packages/endian/core/mail.pyc
vdir /usr/lib/python2.7/site-packages/endian/core/mail*

2. Windows

2.1. Python 3

2.1.1. Installation

  • Note: The python-3.14.2-amd64.exe installation file install Python for all users.

  • Note: The python-manager-25.2.msi and python-manager-25.2.msix installation files install Python only for the current logged on user and the Python Install Manager is an app.

  • Uninstall any previous version.

  • Right-click the python-3.14.3-amd64.exe file and select Run as administrator.

  • Check Use admin privileges when installing py.exe.

  • Check Add python.exe to PATH.

    ■ Use admin privileges when installing py.exe
    ■ Add python.exe to PATH
  • Select Customize installation.

  • Uncheck Documentation.

    □ Documentation
    ■ pip
    ■ Td/Tk, turtle and IDLE
    ■ Python test suite
    ■ py launcher   ■ for all users (requires admin privileges)
  • Click Next.

  • Check Install for all users.

    ■ Install Python 3.14 for all users
    ■ Associate files with Python (requires the 'py' launcher)
    ■ Create shortcuts for installed applications
    ■ Add Python to environment variables
    ■ Precompile standard libary
    □ Download debugging symbols
    □ Download debug binaries (requires VS 2017 or later)
    □ Download free-threaded binaries
    C:\Program Files\Python314
  • Click Install.

  • Click Close.

  • Open Settings.

  • Select Apps > Advanced app settings > App execution aliases.

  • Disable App Installer | python.exe.

  • Disable App Installer | python3.exe.

  • Quit Settings.

2.1.2. Python Virtual Environment

  • Enter the following commands at a Command Prompt with administrative privileges.

    python --version                                                                # 3.7.0
    python -m venv Python3
    dir Python3
    echo %Path%
    powershell -ExecutionPolicy Bypass $Env:Path -split ';'