conda env remove -n old-env
❌ → python=3 may pull 3.12 unexpectedly. Always specify minor version: python=3.10 . building data science solutions with anaconda
conda list --export > conda-requirements.txt # Or use conda-lock for exact binaries conda install conda-lock conda-lock -f environment.yml | Practice | Why it matters | |----------|----------------| | Use environment.yml for everything | No manual conda install – guarantees reproducibility. | | Version-lock critical packages | pandas=2.0.3 not just pandas . | | Keep data separate from code | Use data/raw , data/processed , never commit large files. | | Add a Makefile or shell script | Automate conda env create , conda activate , python train.py . | | Test with a fresh environment | conda env create -f environment.yml --prefix ./test_env to verify. | 7. Common Pitfalls & How to Avoid Them ❌ Mixing pip and conda carelessly → Can lead to broken dependencies. If needed, install everything with conda first, then use pip for remaining packages. conda env remove -n old-env ❌ → python=3 may pull 3
jupyter notebook Your notebook automatically uses the correct kernel. import pandas as pd from sklearn.ensemble import RandomForestClassifier import joblib df = pd.read_csv("data/raw/churn.csv") X = df.drop("churn", axis=1) y = df["churn"] | | Version-lock critical packages | pandas=2