The Founder’s Guide:

How to Set Up a Virtual Environment With a Different Python Version on Windows

The expanded tutorial with explanations and screenshots

David Littlefield
The Startup

--

Image by Pineapple Supply Co.

The condensed version of this article contains copy and paste code that can get the outcome in minutes.

Open PowerShell:

PowerShell is the program that replaced Command Prompt as the default system shell in Windows 10. It’s a shell and an object-oriented scripting language that’s used to automate repetitive tasks and configure system settings. It allows users to automate practically anything in Windows 10.

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Right-click “Windows PowerShell”
  4. Click “Run as Administrator”

The “Run as Administrator” option grants the program permission to make changes to files, system settings, and registry settings.

Check the Default Version:

The Version (V) option is used to check which version of Python is currently selected as the default version. It consists of three numbers separated by periods that represent the major, minor, and micro version number. It also displays an error message if Python isn’t already installed on the computer.

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python --version

Open the Python Directory:

The Change Directory (cd) command is used to change the current working directory to the specified directory. It can navigate to absolute and relative paths that start from the root and current working directory, respectively. It can also navigate to paths stored in variables and environment variables.

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
cd $HOME\appdata\local\programs\python

Copy the Executable File:

The Copy command is used to duplicate a specified file or group of files to the specified location on the computer. It can create an exact copy of files and save them as the original or different file names. It also automatically overwrites files that have the same name without asking for confirmation.

  1. Find the current version in the list below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
copy Python35\python.exe python35.exe
Python 3.6:
copy Python36\python.exe python36.exe
Python 3.7:
copy Python37\python.exe python37.exe
Python 3.8:
copy Python38\python.exe python38.exe

Check the System Type:

The System Type states whether the computer has a 32-bit or 64-bit central processing unit (CPU). It runs a 32-bit version of Windows 10 on older 32-bit CPUs with up to 4 gigabytes (GB) of random access memory (RAM). Or it runs a 64-bit version on modern 64-bit CPUs with up to 128 GB of RAM.

  1. Press “⊞ Windows”
  2. Enter “About” into the search bar
  3. Click “About Your PC”

Download Python:

Python is an object-oriented language that’s known for its simple syntax, code readability, and English-like commands. It gets used for web, back end, and software development but it’s become one of the most popular languages for artificial intelligence, machine learning, and data science.

  1. Visit the official website: [3.5] [3.6] [3.7] [3.8]
  2. Scroll to the “Looking for a specific release?” section
  3. Scroll to the “Files” section
  4. Download the “Executable Installer” that matches the system type

Open the Executable File:

The Executable File (exe) is a computer file that’s only used to run programs and scripts when it’s opened. It performs a task or set of tasks according to the code or series of instructions contained in the program or script. It can also contain a virus depending on whether it came from a trusted source.

  1. Double-click the Python file
  2. Check the “Add Python ** to PATH” box
  3. Click “Install Now”

Copy the Executable File:

The Copy command is used to duplicate a specified file or group of files to the specified location on the computer. It can create an exact copy of files and save them as the original or different file names. It also automatically overwrites files that have the same name without asking for confirmation.

  1. Find the new version in the list below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
copy Python35\python.exe python35.exe
Python 3.6: <----------
copy Python36\python.exe python36.exe
Python 3.7:
copy Python37\python.exe python37.exe
Python 3.8:
copy Python38\python.exe python38.exe

Open the Environment Variables:

The Environment Variable is a variable that’s automatically created and maintained by the computer. It helps the system know where to install files, find programs, and check for user and system settings. It can also be used by graphical and command-line programs from anywhere on the computer.

  1. Press “⊞ Windows”
  2. Enter “Environment Variables” into the search bar
  3. Click “Edit the System Environment Variables”
  4. Click “Environment Variables…”

Open the PATH:

The PATH is an environment variable that contains the list of directories the computer uses to find executable files. It looks for the requested executable file in each directory on the list from top to bottom. It also stops searching once it finds a matching executable file and runs the program or command.

  1. Select “Path” in the “User Variables” section
  2. Click “Edit”

Set the Default Version:

The Default Version is the particular version of Python and pip that’s used when the commands are executed. It gets automatically determined based on which Python directories are listed first in the PATH on Windows 10.

  1. Find the new version from below these instructions
  2. Select the provided paths in the PATH
  3. Click “Move Up”
  4. Click “Move Up” until the new version is the first two items in the PATH
  5. Click “OK”
  6. Click “OK”
  7. Click “OK”
Python 3.5:
C:\Users\Admin\AppData\Local\Programs\Python\Python35\Scripts\
C:\Users\Admin\AppData\Local\Programs\Python\Python35\
Python 3.6: <----------
C:\Users\Admin\AppData\Local\Programs\Python\Python36\Scripts\
C:\Users\Admin\AppData\Local\Programs\Python\Python36\
Python 3.7:
C:\Users\Admin\AppData\Local\Programs\Python\Python37\Scripts\
C:\Users\Admin\AppData\Local\Programs\Python\Python37\
Python 3.8:
C:\Users\Admin\AppData\Local\Programs\Python\Python38\Scripts\
C:\Users\Admin\AppData\Local\Programs\Python\Python38\

Open the Desktop Directory:

The Change Directory (cd) command is used to change the current working directory to the specified directory. It can navigate to absolute and relative paths that start from the root and current working directory, respectively. It can also navigate to paths stored in variables and environment variables.

  1. Copy the command from below these instructions
  2. Paste the provided command into PowerShell
  3. Press “Enter”
cd $HOME\desktop

Install Virtualenv:

Virtualenv is a program that’s used in Python to create and manage virtual environments. It can specify which Python version and directory is used to create the virtual environment. It also installs all the necessary files into the specified directory instead of the systemwide Python installation directory.

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
python -m pip install virtualenv

Create the Virtual Environment:

Virtualenv is a command that’s used in Virtualenv to create isolated Python environments. It specifies the name of the installation directory that stores the virtual environment. It can also specify the version of Python that’s used to create the virtual environment but it uses the default version by default.

  1. Find the new version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
python -m virtualenv --python python35 venv35
Python 3.6: <----------
python -m virtualenv --python python36 venv36
Python 3.7:
python -m virtualenv --python python37 venv37
Python 3.8:
python -m virtualenv --python python38 venv38

Activate the Virtual Environment:

The Activate script is used to install and use binary packages in the virtual environment. It adds the virtual environment directory that contains the Python and pip executable files to the shell PATH. This sets the interpreter and package manager in the virtual environment as the default versions.

  1. Find the new version from below these instructions
  2. Copy the provided command
  3. Paste the command into PowerShell
  4. Press “Enter”
Python 3.5:
venv35\scripts\activate
Python 3.6: <----------
venv36\scripts\activate
Python 3.7:
venv37\scripts\activate
Python 3.8:
venv38\scripts\activate

Install the Binary Packages:

The Binary Package is an archive file that contains the files and directories needed to make its containing program work as expected. It’s stored in a repository that contains other packages for a specific Linux distribution. It also needs the Linux package manager to download, extract, and install it.

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
pip install tensorflow tensorflow-gpu

Deactivate the Virtual Environment:

The Deactivate command is used to shut down the virtual environment. It removes the virtual environment directory from the shell PATH. It also sets the interpreter and package manager back to the regular default versions.

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
deactivate

“Hopefully, this article helped you get the 👯‍♀️🏆👯‍♀️, remember to subscribe to get more content 🏅”

Next Steps:

This article is part of a series that helps you set up everything you need to start using artificial intelligence, machine learning, and deep learning. It contains expanded guides that provide definitions of terms and commands to help you learn what’s happening. It also contains condensed guides that provide instructions and screenshots to help you get the outcome faster.

Linux:
01. Install and Manage Multiple Python Versions
02. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
03. Install the Jupyter Notebook Server
04. Install Virtual Environments in Jupyter Notebook
05. Install the Python Environment for AI and Machine Learning
WSL2:
01. Install Windows Subsystem for Linux 2
02. Install and Manage Multiple Python Versions
03. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
04. Install the Jupyter Notebook Server
05. Install Virtual Environments in Jupyter Notebook
06. Install the Python Environment for AI and Machine Learning
07. Install Ubuntu Desktop With a Graphical User Interface (Bonus)
Windows 10:
01. Install and Manage Multiple Python Versions
02. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
03. Install the Jupyter Notebook Server
04. Install Virtual Environments in Jupyter Notebook
05. Install the Python Environment for AI and Machine Learning
MacOS:
01. Install and Manage Multiple Python Versions
02. Install the Jupyter Notebook Server
03. Install Virtual Environments in Jupyter Notebook
04. Install the Python Environment for AI and Machine Learning

Glossary:

Glossary:

The Shell is an interpreter that presents the command-line interface to users to let them interact with the kernel. It lets them control the computer using commands entered from a keyboard. It also translates the commands from the programming language into the machine language for the kernel.
[Return]

The Interpreter is a program that reads through programs that are written in human-readable programming languages and executes the instructions from top to bottom. It translates each instruction to a machine language the
hardware can understand, executes it, and proceeds to the next instruction.
[Return]

The Command-Line Interface (CLI) is also known as the terminal or console. It’s a program that accepts text input from users to execute commands on the operating system. It lets users configure the computer, install software, and access features that aren’t available in the graphical user interface.
[Return]

The Kernel is the program at the core of the operating system that controls everything in the system. It’s responsible for memory management, process management, disk management, and task management. It also facilitates communication between the programs and hardware in machine language.
[Return]

The Major version is a number that represents an update that introduces significant changes to a program. It can add different architecture, features, and functionality that’s incompatible with previous versions. This usually causes programs that were built with a previous version to stop working.
[Return]

The Minor version is a number that represents an update that introduces moderate changes to a program. It can add small features and functionality that’s compatible with the latest major update. This usually doesn’t cause problems with programs that were built with the previous minor updates.
[Return]

The Micro version is a number that represents an update that introduces very modest changes to a program. It can add bug fixes and performance enhancements that are compatible with the previous updates. This doesn’t cause problems with programs that were built with the previous updates.
[Return]

The Variable is the container that’s used to store different types of values. It can assign or update a value by placing an equals sign between the specified variable name and value without space around it. It can also reference the stored value by placing the dollar sign in front of an existing variable name.
[Return]

The Virtual Environment is an isolated Python installation directory that contains its own interpreter, site-packages, and scripts. It’s used to avoid version conflicts between dependencies from different programs. It’s also used to meet the dependency requirements of Linux programs on GitHub.
[Return]

The Site-Packages is a directory that’s located in the system-wide Python installation directory. It’s the default path that package managers use to
install third-party binary packages. It’s also one of the paths that Python uses to locate and import binary packages that are already installed.
[Return]

The Dependencies are the additional binary packages that a specific binary package needs to work properly. They’re relied on by nearly every package that’s distributed in Linux. They’re also automatically located, downloaded, and installed when a package is installed using the Linux package manager.
[Return]

--

--

David Littlefield
The Startup

From: Non-Technical | To: Technical Founder | Writes: To Make It Easier For Everyone | Topics: #Startups #How-To #Coding #AI #Machine Learning #Deep Learning