Update docs/tech_docs/Python-Virtual-Environments.md
This commit is contained in:
@@ -1,5 +1,86 @@
|
|||||||
# Setting Up a Virtual Environment for KnowledgeBase-Tech Hugo Site
|
# Setting Up a Virtual Environment for KnowledgeBase-Tech Hugo Site
|
||||||
|
|
||||||
|
## Update PATH Environment Variable
|
||||||
|
|
||||||
|
Before installing `virtualenv`, ensure your PATH includes the directory where Python packages are installed. If you see a message like "The script virtualenv is installed in '/home/medusa/.local/bin' which is not on PATH," you'll need to update your PATH. Add the following line to your `.bashrc` or `.profile` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, reload your profile:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source ~/.bashrc
|
||||||
|
```
|
||||||
|
|
||||||
|
or for a login shell:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source ~/.profile
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install Virtual Environment
|
||||||
|
|
||||||
|
Ensure Python and pip are installed, then install `virtualenv`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip3 install virtualenv
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create the Virtual Environment
|
||||||
|
|
||||||
|
Create a virtual environment named `KnowledgeBase-Tech_env`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
virtualenv KnowledgeBase-Tech_env
|
||||||
|
```
|
||||||
|
|
||||||
|
## Activate the Virtual Environment
|
||||||
|
|
||||||
|
To start using the virtual environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source KnowledgeBase-Tech_env/bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
## Install Dependencies
|
||||||
|
|
||||||
|
While the environment is active, install any required packages:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install <package-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Freeze Requirements
|
||||||
|
|
||||||
|
To keep track of your project's dependencies, you can freeze the installed packages into a `requirements.txt` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip freeze > requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
This file can be used to install the exact versions of the required packages on other setups or by other developers working on the project.
|
||||||
|
|
||||||
|
## Deactivate the Virtual Environment
|
||||||
|
|
||||||
|
When you're done working, deactivate the environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
deactivate
|
||||||
|
```
|
||||||
|
|
||||||
|
## Working with the Environment
|
||||||
|
|
||||||
|
Remember to activate the `KnowledgeBase-Tech_env` environment every time you work on the KnowledgeBase-Tech Hugo site. This ensures all dependencies are isolated to this specific project.
|
||||||
|
````
|
||||||
|
|
||||||
|
Replace `<package-name>` with the specific packages you need for your Hugo site. The addition of the freeze requirements section will help maintain a consistent set of dependencies across different development environments.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Setting Up a Virtual Environment for KnowledgeBase-Tech Hugo Site
|
||||||
|
|
||||||
## Install Virtual Environment
|
## Install Virtual Environment
|
||||||
|
|
||||||
First, ensure Python and pip are installed, then install `virtualenv`:
|
First, ensure Python and pip are installed, then install `virtualenv`:
|
||||||
|
|||||||
Reference in New Issue
Block a user