We will explore various ways to install Python and related tools on a Windows OS. We will start with installing Python onto Windows command and how to start a Virtualenv session. We will explore how we can use Docker containers to run Python on Ubuntu from a Windows OS.
Install and configure Python
To install Python onto Windows using the following link:
Verify that Python is installed correctly by querying the version using the below command. If you encounter '''Python' is not recognized as an internal or external command ..." while using the CMD command line, check that python is part of the Path environment variable.
python --version python
To obtain an isolated python environment install Virtualenv using python's package management system known as PIP (source). The following command shows how to install and create an isolated environment:
python pip install virtualenv virtualenv target_directory source /target_directory/Scripts/activate.bat
The DockerFile below is used to create an environment for running Python. The file uses a base Linux (Ubuntu) image with Python installed. The pip.conf file defines custom repository locations used to retrieve python packages.
FROM ubuntu VOLUME ubuntu_content COPY content /ubuntu_content RUN apt -y update RUN apt-get -y update RUN apt install -y python3 RUN apt install -y python3-pip RUN apt install -y virtualenv RUN apt install -y wget RUN mkdir ~/.pip/ RUN cp /ubuntu_content/pip.conf ~/.pip/pip.conf RUN pip3 install --ignore-installed --no-cache-dir <python_tool_name> RUN wget https://<url_to_executable_python_tool> RUN chmod u+x /<python_tool_name> #RUN /<python_tool_name> "$@" --outputDir="/ubuntu_content" && source
Below shows a script used to build the DockerFile: