Sunday, 4 July 2021

*Episode 4* PYTHON (Virtual Environment of Python)


Creating virtual environments


This Episode covers:-


 1.) How to create virtual environments in Windows.

 2.) How to create virtual environments in macOS.

 3.) How to create virtual environments in Linux.



👉Creating and activating virtual environments in Windows:-


      Create a new directory for the projects:

Terminal

mkdir projects

cd projects


       venv command creates the virtual environment. Activate it with the activate.bat script:

Terminal

python -m venv venv

venv\Scripts\activate.bat


      The (venv) prefix indicates that the environment is active:

Terminal

(venv) C:\Users\samul\projects>


      Rest of the book will mostly be the same for all operating systems.


Summary


  •  You can use the venv command to create virtual environments.
  •  Make sure to active the virtual environment before you start working on a project.



👉Creating and activating virtual environments in macOS:-

      Create a new directory for the projects:
Terminal
mkdir projects
cd projects


      venv command creates the virtual environment. Activate it using the source
command:
Terminal
python3 -m venv venv
source venv/bin/activate


      Source command reads and executes commands from a file.

      The (venv) prefix indicates that the environment is active:
Terminal
(venv) ~


      Rest of the book will mostly be the same for all operating systems.


Summary

  •  You can use the venv command to create virtual environments.
  •  Make sure to active the virtual environment before you start working on a project.



 ðŸ‘‰Creating and activating virtual environments in Linux :-


     Create a new directory for the projects:
Terminal
mkdir projects
cd projects


      venv command creates the virtual environment. Activate it using the source
command:
Terminal
sudo apt-get install python3-venv
python -m venv venv
source venv\bin\activate


      Source command reads and executes commands from a file.

      The (venv) prefix indicates that the environment is active:
Terminal
(venv) samuli@box:~/projects$


      Rest of the book will mostly be the same for all operating systems.


Summary

  •  You can use the venv command to create virtual environments.
  •  Make sure to active the virtual environment before you start working on a project.

👈Episode 3 (P).                                                                                              Episode 5(P)👉
Share This Post

PRINT THIS POST

No comments:

Post a Comment

If you have any doubts. Please let me know.

Featured post

*Episode 1* MCQ for Govt. Job/ Private Job/ MNCs

  Topic:- One Word Substitution 1) Especially skilled in storytelling  Answer:- Raconteur 2) Fear of loneliness Answer:- Eremophobia  3) Usa...