๐ฆ Virtual Environments
Virtual environments allow you to manage dependencies for different projects separately.
Mastering this concept will significantly boost your Python data science skills!
๐ป Code Example:
# โโ Python Virtual Environments โ Complete Reference โโโโโโโโโ # 1. Create a new virtual environment python -m venv pynfinity_env # 2. Activate # Windows: pynfinity_env\Scripts\activate # macOS / Linux: source pynfinity_env/bin/activate # 3. Verify you are inside the virtual env which python # (Linux/Mac) should point to pynfinity_env/bin/python python --version # e.g., Python 3.12.3 # 4. Install packages pip install flask pandas requests # 5. Freeze exact dependency versions for reproducibility pip freeze > requirements.txt # 6. Install from requirements.txt on another machine / CI pip install -r requirements.txt # 7. View installed packages pip list --format=columns # 8. Deactivate environment deactivate # 9. Delete environment cleanly rm -rf pynfinity_env # Linux/Mac # On Windows: Remove-Item -Recurse pynfinity_env # 10. Using venv with VS Code # Press Ctrl+Shift+P โ "Python: Select Interpreter" โ choose pynfinity_env # โโ Alternative: pipenv (higher-level tool) โโโโโโโโโโโโโโโโโโโ pip install pipenv pipenv install flask pandas pipenv shell # Activate pipenv run python app.py # Run without activating
Keep exploring and happy coding! ๐ป