From ec2a79e932e62d4c18db22b3a6de9a0349aa85b2 Mon Sep 17 00:00:00 2001 From: Asabeneh Date: Thu, 8 Jul 2021 23:16:24 +0300 Subject: [PATCH] vitrual env --- .../23_virtual_environment.md | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/23_Day_Virtual_environment/23_virtual_environment.md b/23_Day_Virtual_environment/23_virtual_environment.md index 2ff4eb70..d23b45ce 100644 --- a/23_Day_Virtual_environment/23_virtual_environment.md +++ b/23_Day_Virtual_environment/23_virtual_environment.md @@ -9,10 +9,8 @@ Author: Asabeneh Yetayeh
- First Edition: Nov 22 - Dec 22, 2019 + Second Edition: July, 2021
- - [<< Day 22](../22_Day_Web_scraping/22_web_scraping.md) | [Day 24 >>](../24_Day_Statistics/24_statistics.md) @@ -30,9 +28,11 @@ To start with project, it would be better to have a virtual environment. Virtual environment can help us to create an isolated or separate environment. This will help us to avoid conflicts in dependencies across projects. If you write pip freeze on your terminal you will see all the installed packages on your computer. If we use virtualenv, we will access only packages which are specific for that project. Open your terminal and install virtualenv ```sh -asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ pip install virtualenv +asabeneh@Asabeneh:~$ pip install virtualenv ``` +Inside the 30DaysOfPython folder create a flask_project folder. + After installing the virtualenv package go to your project folder and create a virtual env by writing: For Mac/Linux: @@ -43,27 +43,33 @@ asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project\$ virtualenv venv For Windows: ```sh -C:\Users\User\Documents\30DaysOfPython\flask_project>python3 -m venv venv +C:\Users\User\Documents\30DaysOfPython\flask_project>python -m venv venv ``` -I prefer to call the new project venv, but feel free to name it differently. Let's check if the the venv was created by using ls (or dir for windows command prompt) command. +I prefer to call the new project venv, but feel free to name it differently. Let us check if the the venv was created by using ls (or dir for windows command prompt) command. ```sh asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ ls venv/ ``` -Let's activate the virtual environment by writing the following command at our project folder. +Let us activate the virtual environment by writing the following command at our project folder. For Mac/Linux: ```sh asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ source venv/bin/activate ``` -For Windows: +Activation of the virtual environment in Windows may very on Windows Power shell and git bash. + +For Windows Power Shell: ```sh C:\Users\User\Documents\30DaysOfPython\flask_project> venv\Scripts\activate ``` +For Windows Git bash: +```sh +C:\Users\User\Documents\30DaysOfPython\flask_project> venv\Scripts\. activate +``` After you write the activation command, your project directory will start with venv. See the example below. @@ -73,13 +79,13 @@ After you write the activation command, your project directory will start with v Now, lets check the available packages in this project by writing pip freeze. You will not see any packages. -We are going to do a small flask project so let's install flask to this project. +We are going to do a small flask project so let us install flask package to this project. ```sh (venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ pip install Flask ``` -Now, let's write pip freeze to see a list of installed packages in the project: +Now, let us write pip freeze to see a list of installed packages in the project: ```sh (venv) asabeneh@Asabeneh:~/Desktop/30DaysOfPython/flask_project$ pip freeze @@ -104,4 +110,5 @@ The necessary modules to work with flask are installed. Now, your project direct 1. Create a project directory with a virtual environment based on the example given above. 🎉 CONGRATULATIONS ! 🎉 + [<< Day 22](../22_Day_Web_scraping/22_web_scraping.md) | [Day 24 >>](../24_Day_Statistics/24_statistics.md)