Python Virutal Environment on Windows

I am an Unix SA and had been from quite a some time and used to work with my Windows Desktop in office and Linux Laptop at home, but during this lockdown I had been left with no choice but to work primarily on a Windows Laptop all the time, I really did not get much time to start my working and development environment, which also begs me to write an ansible playbook, which is for some later day blog. But here is the guide on which I would possible write my Playbook to install python and set thigs up.

Prerequisites:

  • A Windows machine
  • Python installer (if you are the admin of the laptop then all good, otherwise installing this without admin account is another level challenge)
  • Knowledge of working with Windows Command Prompt. (Yes this is going to be totally different that working with Linux Command Prompt)

The setup is quite simple, follow the steps below or just copy and paste all even that is all good.

I am planning to use Python 3.8.3 installed on to my system.

To check if python is installed on your laptop/workstation or not just type on the cmd prompt from the start menu or press “Win + R” -> “cmd”.

Once the command prompt is open, type python on the c: prompt

Display python version on Windows

you should see something like in the screenshot .

Type exit () to come out of the prompt, usual Linux “Ctrl +d” will not work in here. Windows has its own limitations.

Next is to create a virtalenv, where we can do your project work.

I have plans to make a video of this, which I will do sometime sooner for setting up python and virtualenv in windows. #TODO

c:\>mkdir projects

c:\>cd projects

c:\projects>python -m venv my_first_python_program

c:\projects>cd my_first_python_program

c:\projects\my_first_python_program>dir

c:\projects\my_first_python_program>cd Scripts

c:\projects\my_first_python_program\Scripts>activate

(my_first_python_program) c:\projects\my_first_python_program\Scripts>
How to setup a virtual env in windows 10
Steps to steps virtual env in windows

Once you setup and activated the environment, the environment name is added as the prefix of the prompt.

Till the time, you do not “deactivate” your virtual environment. you are not going make any changes to your core operating system libraries.

Now, go download the pip libraries and modules and try out new things.

(my_first_python_program) c:\projects\my_first_python_program\Scripts>pip install jupyter

Finally, Coming out of the virtual enviromnet

(my_first_python_program) c:\projects\my_first_python_program\Scripts>deactivate

c:\projects\my_first_python_program\Scripts>

Thank you for reading and bearing my adventours. 🙂