From 9f82b542419b0f6da5a59c71a8e40d5eee531a6c Mon Sep 17 00:00:00 2001 From: Ken Schaefer Date: Wed, 24 Jul 2024 10:01:44 -0500 Subject: [PATCH] venv --- .gitignore | 1 + virtual-env/readme.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .gitignore create mode 100644 virtual-env/readme.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7462fd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +virtual-env/.env/ \ No newline at end of file diff --git a/virtual-env/readme.md b/virtual-env/readme.md new file mode 100644 index 0000000..c6660b0 --- /dev/null +++ b/virtual-env/readme.md @@ -0,0 +1,25 @@ +## Create virtual environment + +Open Terminal + +- Create a directory to hold your virtual environments, change into it +- Create a virtual environment + - `python -m venv {name-of-env}` Windows + - `python3 -m venv {name}` Linux +- Activate the virtual environment + - `{name-of-env}\Scripts\activate.bat` Windows + - `source {name}/bin/activate` Linux +- Deactivate + - `deactivate` +- Install packages in the environment + - `pip list` + - `pip install requests` +- Publishing an environment + - `pip freeze > requirements.txt` + - Using requirements + - Create a new env + - `pip install -r requirements.txt` +- Best Practices + - Create the project directory + - Create the venv or env folder inside of the project directory + - Source code does not go into the env folder \ No newline at end of file