This post provides specific steps to install Python3 on different operating systems with the goal of easily create a virtual environment for script execution. The process is straightforward and well documented across the Internet so this post serves as a consolidated reference of known working and tested procedures. Let me know if any other examples need to be added.

 

If the machine designated to run scripts runs Linux there is a chance Python3 is possibly already installed. You can test by logging into the device and typing python3 at the prompt. If Python 3 is present, you will see the version along with some other information and it will drop you at a >>> prompt. Congrats, you're halfway there. You can type exit() to exit the Python shell. If you did not see the prompt and the command was not found, you can try installing it with the distribution's package manager.

 

For any of the operating systems you have the option to install Git to easily sync the repository but scripts can always been manually downloaded so it's a matter of preference. Git is probably overkill for Windows, but for most Linux distributions it's easily added. Being optional, I have highlighted Git references in blue in the steps below and they can be safely removed.

 

Debian 8:

Python3 is installed by default.

$ sudo apt-get install -y python3-pip git

$ pip3 install virtualenv

 

Ubuntu 16.4:

Python3 is installed by default.

$ sudo apt-get install -y python3-pip git

$ pip3 install virtualenv

 

Fedora 24:

Python3 installed by default.

$ sudo dnf install -y python3-pip git

$ pip3 install virtualenv

 

Note: Fedora uses 'virtualenv-3' as the executable name so use that instead of virtualenv.

 

CentOS 7:

The EPEL respostory needs to be added first.

  $ wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm

  $ sudo rpm -ivh epel-release-7-8.noarch.rpm

  $ sudo yum install -y python34 git

  $ curl -O https://bootstrap.pypa.io/get-pip.py
  $ sudo /usr/bin/python3 get-pip.py

  $ sudo pip install virtualenv

 

Windows:

For Windows devices, Python3 is downloaded from the download site; choose the package that matches your platform and start the installation.

 

As I mention above, Git is an optional piece and it requires an additional download and installation on Windows. It's likely not worth it to use it to sync one or two repositories, but it doesn't hurt either. Here is the link to optionally download Git. The default options are fine.

 

Check the Add Python 3.5 to PATH box.

blog-win-py.PNG

 

Make sure you close and reopen and cmd windows to refresh the PATH after installation. The Windows package includes pip so you can ensure you have virtualenv installed also with:

 

  $ pip install virtualenv

 

And now we're ready to run some scripts.