Install Python and configure the work environment on windows

06-11-22 Ahmed Obaid 9722 1

Installing or updating Python on your computer is the first step to becoming a Python programmer. There are many ways to install: you can download official Python distributions from Python.org, install from a package manager, and even install specialized distributions for scientific computing, IoT, and embedded systems. But in this article, I will shorten the way for you and put in your hands the easiest ways to install Python on Windows and macOS operating systems.

download and install Python on Windows

First of all, you should check the version of Python that is available by default on your system (it comes pre-installed on the operating system as a system package).

To open the Windows PowerShell command surface


  1. Press the Win key.

  2. Type PowerShell or cmd.

  3. press enter

After opening the command line, type this command to find out the version number of Python that is originally on the operating system


python --version

You will see a result similar to this


Python 3.8.4

If you see a version lower than 3.11, which is the latest version at the time of writing this article, then you should upgrade to the latest version of Python.

Ways to download and install Python on Windows

There are two ways to download Python on Windows by defaultundefined Official:

 1- download and install Python Via Microsoft Store package:

 This method is recommended for novice Python users who are looking for an interactive experience that is easy to set up.

 You can open PowerShell and type the following command:


C:\> python

 If you don't already have a version of Python on your system, when you press Enter, the Microsoft Store will automatically launch and take you to the latest version of Python in the Store.

Or follow this link to download Python 3.11 from Microsoft Store 

Explain how to download and install Python on Windows

 To install Python from the Microsoft Store, follow these steps to complete the installation:


  1.  Click Get.

  2.  Wait for the app to download. When the download is finished, the Get button will be replaced with a button that says Install on my devices.

  3.  Click Install on my devices and select the devices on which you want to complete the installation.

  4.  Click Install Now and OK to start the installation.

 If the installation is successful, you will see the message "This product has been installed" at the top of the Microsoft Store page.

 Warning: Make sure that the Microsoft Store Python application you are installing was created by the Python Software Foundation. The official Microsoft Store bundle is always free, so if an app costs money, undefined This app is wrong.

 2- download and install Python via Python.org:

This method involves downloading Python directly from the Python.org website. This is recommended for intermediate and advanced developers who need more control during the setup process.

 Follow this link to download Python from the official website 

 Note: I prefer to install from the official Python website, Python.org, as the installation will not be restricted by Windows policies.

 Follow these steps to download the full installer from Python.org:


  1.  Open a browser window and go to the Python.org Downloads for Windows page.

  2.  Under "Python versions for Windows" click on the link for the latest version of Python 3 - Python 3.xx. As of this writing, the latest release is Python 3.11.

  3.  Scroll to the bottom and select either Windows x86-64 Executable Installer for 64-bit or Windows x86 Executable Installer for 32-bit.

  4.  When the installer has finished downloading, go to the next step.

  5.  Run the installer, run it by double clicking on the downloaded file. A dialog like the one below will appear

 Click close at undefined Installation finished.



3- Install PIP

Python3 usually comes with pip pre-installed, however, if you get the error “pip command not found”, just use the following method to install pip.


curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Download get-pip.py, and make sure to save the file to your desktop.

At the Windows command prompt, go to your desktop and run the get-pip.py script.


python3 get-pip.py

Note: You may need to have administrative privileges in Command Prompt to accomplish this task. For more information about this, follow the instructions from Start a command prompt as an administrator from the Microsoft website


cd Desktop
Python get-pip.py

4- How to install Virtualenv

"A default environment is a Python environment such that the Python interpreter and the libraries and scripts installed in it are isolated from those installed in other virtual environments, and (by default) any libraries installed in the Python 'system', that is, installed as part of your operating system"

When you activate the virtual environment for your project, your project becomes a stand-alone application, independent of the installed Python system and its modules.undefined stereotypes.

 Your new virtual environment has its own points for installing libraries, its own libraries folder where new libraries are added, and its own Python interpreter for the version of Python you used to activate the environment.

 At your Windows command prompt, type the following:


 pip install virtualenv

 In your windows command prompt, head to your project folder: python -m venv

 Example:


 mkdir project
cd project
python3.11 -m venv env

 When you check the new project folder, you will notice that a new folder called env has been created. env is the name of our default environment, but it can be called anything you like.

 Activate the virtualenv environment

 To activate Virtualenv on Windows, activate the script located in the Scripts folder:


env/Scripts/activate.bat //In CMD
env/Scripts/Activate.ps1 //In Powershel

 Example:


 C:\Users\'Username'\env\Scripts\activate.bat

 more information:

 You may wish to refer to the following resources for additional information on this topic.

 Documenting Python: Creating a Virtual Environment



Conclusion:

You can now have access to the latest version of Python for your system. Your journey in learning Python has just begun.

In this lesson, you learned how to:


  1. Check the version of Python installed on your system, if any

  2. installed the latest version of Python on Windows

  3. قمنا بتهيئة بيئة العمل

You are now ready to start learning the programming language in Python! Be sure to share your learning progress and ask any questions you might have in the comments below.



Tags


Python windows

Share page