Today at Arzhost, we discuss how we Update Python in Virtualenv in Windows and Linux. We’ll look at how to update Python in the Windows system in this article. For protest purposes, we shall update Python from version 3.6.8 to version 3.9.6. Use the following command in the command prompt to see what version of Python is currently installed on your computer:
This will display the Python version you are currently using, as demonstrated below:
Using the installer’s executable:
To update your Python version, take the following actions:
Step by Step Guide of Update Python in Virtualenv
Step 1: Visit the Python website.
Phase 2: Select the Downloads tab.
Step 3: Depending on your system requirements, download the version you need to update to (ie, 32-bit or 64-bit). Here, we will get the 3.9.6 installer for 64-bit systems.
Step 4: Click the installer to start the installation process. Make certain to choose “Add Python 3.9 to PATH.” click “Install Now” after that.
The installation will begin as indicated below:
Following a successful installation, you will see the following message:
Now, if you open cmd and enter the following command:
You can see that Python has been updated to version 3.9.6 as indicated below:
Python Package Updates for Windows and Linux
On Linux or Windows, Pip can be use to upgrade all packages:
1: Create a requirements file (requirements.txt) and output a list of installed packages in it:
pip freeze > specifications.txt
2: In requirements.txt, change every
'==' to a '>='. Use the editor’s ‘Replace All’ command.
3: Upgrade all out-of-date software:
txt, pip install -r —upgrade
All Packages in A Virtual Environment Are Update
Running the Update Python in Virtualenv script below, which uses pip, is the simplest way to update unpinned packages (i.e., packages that do not need a specific version) in a virtual environment:
from sub-process import call
for dist in pkg_resources. working set:
call ("python -m pip install --upgrade " + dist.<project name>, shell=True)