-
Notifications
You must be signed in to change notification settings - Fork 2
Python Virtual Environment Primer
This guide helps you create and activate an isolated Python environment using venv on Windows, macOS, and Linux.
- Python 3.x installed (preferably 3.6+)
-
venvmodule is included by default with Python 3.3+ - Verify your installation:
python --version # or python3 --version
To create a virtual environment (named pypolar_env, though you can choose any name), open a terminal or command prompt in your project directory and run the following command:
python -m venv pypolar_envpython3 -m venv pypolar_envThis creates a subdirectory called pypolar_env/ that contains the isolated Python interpreter and dependencies.
pypolar_env\Scripts\activatepypolar_env\Scripts\Activate.ps1Note: If you get an execution policy error in PowerShell, run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
source pypolar_env/bin/activateWhen activated, your shell prompt will prefix with (pypolar_env).
Once the environment is active:
-
Install packages with
pip, e.g.,Polarimetry:pip install polarimetry
-
These packages will be isolated to the virtual environment.
When you're done working in the virtual environment, deactivate it:
deactivatepip listpip freeze > requirements.txtpip install -r requirements.txt- You can safely delete the
pypolar_env/folder to remove the environment. - IDEs like VS Code automatically detect and use the
pypolar_envif placed in your project folder. - For project-based work, it is good practice to include the
pypolar_env/folder in your.gitignore.
PyPOLAR is developed under the BSD 2-Clause License, Copyright Β© 2021 Β β’Β cristel.chandre@cnrs.fr
Tutorials
- Tutorial 1 (basic analysis)
- Tutorial 2 (mask and ROI)
- Tutorial 3 (batch analysis)
- Tutorial 4 (reference angle and boundary)
- Tutorial 5 (figures and colorbars)