Python Packages#
Virtual Environments#
It is best practice to create a virtual environment for each project. This keeps dependencies isolated and avoids version conflicts.
First, create a project folder and navigate into it:
mkdir my-project
cd my-project
Then create and activate a virtual environment inside that folder:
# Create a virtual environment
python -m venv .venv
# Activate it
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
The .venv folder contains the isolated Python installation. All packages you install with pip while the environment is active are stored there.
Tip
VS Code and PyCharm can automatically detect and activate virtual environments.
Anaconda
Anaconda uses its own environment system (conda) instead of venv. You can create environments via Anaconda Navigator (Environments tab) or via the command line:
conda create -n my-project python=3.12
conda activate my-project
Do not mix venv and conda — use one or the other. If you installed Python via Anaconda, use conda environments.
Installing Packages#
Use pip to install packages:
pip install pandas plotly pyedautils
Or install all packages used in this book at once:
pip install -r requirements.txt
Anaconda users — use conda instead of pip!
If you are using Anaconda, always install packages via Anaconda Navigator or conda install instead of pip:
conda install pandas plotly statsmodels
Mixing pip and conda in the same environment can lead to broken dependencies — conda manages packages differently than pip, and installing with pip can overwrite or conflict with conda-managed packages. This may result in import errors, version mismatches, or a corrupted environment that needs to be recreated.
If a package is not available via conda (e.g. pyedautils), install it with pip as a last resort, but do so after all conda packages are installed.
Key Packages#
Package |
Purpose |
|---|---|
Data manipulation and analysis |
|
Numerical computing |
|
Interactive visualizations |
|
Static visualizations |
|
Energy data analysis utilities — ready-to-use analysis and visualization functions |
|
Time series decomposition and statistics |
Updating Packages#
pip install --upgrade pyedautils