Virtual Environment Activation Guide (Windows and Ubuntu)
This guide provides instructions for activating Python virtual environments in Windows (Command Prompt and PowerShell) and Ubuntu (Bash).
1. Creating a Virtual Environment (Common Step)
Regardless of your operating system, create a virtual environment using the following command:
Bash
python -m venv venv_api
Replace venv_api
with your desired virtual environment name.
2. Activating the Virtual Environment
Windows (Command Prompt - cmd.exe):
Navigate to your project directory:
DOS
cd path\to\your\project\crypto_api
Replace path\to\your\project\crypto_api
with the actual path.
Activate the virtual environment:
DOS
venv_api\Scripts\activate.bat
Windows (PowerShell):
Navigate to your project directory:
PowerShell
cd path\to\your\project\crypto_api
Replace path\to\your\project\crypto_api
with the actual path.
Activate the virtual environment:
PowerShell
.\venv_api\Scripts\activate
Ubuntu (Bash):
Navigate to your project directory:
Bash
cd /path/to/your/project/crypto_api
Replace /path/to/your/project/crypto_api
with the actual path.
Activate the virtual environment:
Bash
source venv_api/bin/activate
Or if already inside the venv_api folder.
Bash
source bin/activate
3. After Activation
Your command prompt will change to indicate the active virtual environment:
(Windows cmd.exe): (venv_api) D:\path\to\your\project\crypto_api>
(Windows PowerShell): (venv_api) PS D:\path\to\your\project\crypto_api>
(Ubuntu): (venv_api) user@hostname:~/path/to/your/project/crypto_api$
4. Deactivating the Virtual Environment (Common Step)
To deactivate the virtual environment, use the following command in all environments:
Bash
deactivate
Troubleshooting (Ubuntu):
"Permission denied" error: If you encounter this error, run:
Bash
chmod +x venv_api/bin/activate
Incorrect path: Always double-check your paths.