Update docs/tech_docs/Python-Virtual-Environments.md
This commit is contained in:
@@ -1,3 +1,62 @@
|
||||
**Install Python and pip (if not already installed):**
|
||||
Ubuntu 22.04 typically comes with Python 3 installed. You can check if Python is installed and its version by running:
|
||||
```bash
|
||||
python3 --version
|
||||
```
|
||||
To install pip, run:
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install python3-pip
|
||||
```
|
||||
|
||||
2. **Install Virtual Environment:**
|
||||
With pip installed, you can now install `virtualenv`, which is a tool for creating isolated Python environments. Run the following command:
|
||||
```bash
|
||||
pip3 install virtualenv
|
||||
```
|
||||
|
||||
3. **Create a Virtual Environment:**
|
||||
Navigate to the directory where you want to set up your Mkdocs site and create a virtual environment. Replace `myenv` with your preferred environment name.
|
||||
```bash
|
||||
virtualenv myenv
|
||||
```
|
||||
|
||||
4. **Activate the Virtual Environment:**
|
||||
To start using the virtual environment, you need to activate it. Run:
|
||||
```bash
|
||||
source myenv/bin/activate
|
||||
```
|
||||
Once activated, your command prompt should change to indicate that you are now working inside `myenv`.
|
||||
|
||||
5. **Install Mkdocs in the Virtual Environment:**
|
||||
With your virtual environment active, install Mkdocs:
|
||||
```bash
|
||||
pip install mkdocs
|
||||
```
|
||||
|
||||
6. **Create Your Mkdocs Project:**
|
||||
After Mkdocs is installed, you can create a new Mkdocs project:
|
||||
```bash
|
||||
mkdocs new my-project
|
||||
```
|
||||
Replace `my-project` with your project name. This will create a new directory with a basic configuration.
|
||||
|
||||
7. **Run Mkdocs Locally:**
|
||||
To see your Mkdocs site, navigate to your project directory and run:
|
||||
```bash
|
||||
cd my-project
|
||||
mkdocs serve
|
||||
```
|
||||
This command starts a local server. You can view your site by going to `http://127.0.0.1:8000` in your web browser.
|
||||
|
||||
8. **Deactivate the Virtual Environment:**
|
||||
When you’re done working in the virtual environment, you can deactivate it by running:
|
||||
```bash
|
||||
deactivate
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# `venv` User Guide for Python Virtual Environments
|
||||
|
||||
The `venv` module, included in Python 3, is used for creating isolated Python environments. This guide provides instructions on creating and managing virtual environments with `venv`.
|
||||
|
||||
Reference in New Issue
Block a user