From 70a5df36c84f1c6a022ecabb6ba4fc95b1be18f0 Mon Sep 17 00:00:00 2001 From: medusa Date: Sat, 13 Jan 2024 17:34:06 +0000 Subject: [PATCH] Update docs/tech_docs/Python-Virtual-Environments.md --- docs/tech_docs/Python-Virtual-Environments.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/tech_docs/Python-Virtual-Environments.md b/docs/tech_docs/Python-Virtual-Environments.md index d7d07ff..a031d7a 100644 --- a/docs/tech_docs/Python-Virtual-Environments.md +++ b/docs/tech_docs/Python-Virtual-Environments.md @@ -1,3 +1,58 @@ +## Standard Directory Structure for Python Projects on Debian + +In a Python project, particularly on a Debian Linux system, it's important to follow a standard directory structure for organization and efficiency. Here is a recommended structure: + +1. **src or app**: This directory holds the source code of the project. + ```bash + mkdir src + ``` + +2. **docs**: This is where all the documentation related to the project should be kept. + ```bash + mkdir docs + ``` + +3. **tests**: This directory will contain test scripts and test data. + ```bash + mkdir tests + ``` + +4. **data**: If your project requires any data files, store them here. It's useful for projects that need to access datasets or other resources. + ```bash + mkdir data + ``` + +5. **env**: This is for the Python virtual environment. Although it's common to place it in the project root, some prefer to keep it outside to prevent its accidental inclusion in version control systems like Git. + - To create a virtual environment in Debian, navigate to your project root and run: + ```bash + python3 -m venv env + ``` + - Remember to add `env/` to your `.gitignore` file if you decide to place it within the project root. + +### Activating the Virtual Environment on Debian + +- After creating the virtual environment, you can activate it using: + ```bash + source env/bin/activate + ``` + +### Deactivating the Virtual Environment + +- To exit the environment, simply run: + ```bash + deactivate + ``` + +### Tips for Debian Users + +- Always activate your virtual environment before starting work on the project. +- Install project-specific Python packages within the virtual environment to avoid conflicts with system-wide packages. +- Regularly update your `requirements.txt` file to keep track of dependencies. +- Use relative paths in your scripts and tools for better portability and flexibility. + +By following this structure and these tips, you can maintain a well-organized and efficient development environment for your Python projects on Debian. + +--- # Setting Up a Virtual Environment for KnowledgeBase-Tech Hugo Site ## Update PATH Environment Variable