Setup a python development environment on Mac with uv
This is my favorite way to setup an environment. Alternatively we could use conda (Anaconda or mini-conda) which has some advantages but uv approach is fast and thus preferred.
- Install uv - UV is a fast python package and project manager, written in Rust. This is one of the best approaches to setting up virtual environments for each project. Other approaches are to use mini-conda or Anaconda which comes with several packages pre-installed. I personally use uv to setup the environment and use VSCode as editor for both python and notebook files.
curl -LsSf https://astral.sh/uv/install.sh | sh
- Create a project
uv init my_project
cd my_project
- Create a virtual environment
uv python install 3.12
uv venv --python 3.12
source .venv/bin/activate
- For IDE one can use VS Code or PyCharm. Both offer good support for running and debugging python code. VS Code also supports running notebooks locally but for most practical purposes we will end up running the notebooks in Google Collab or Kaggle or similar such Jupyter environment with GPU/TPU infra to run ML code.
- Select the python virtual environment created as the interpreter in the IDE.
Install local LLM using Ollama
- Install ollama from https://ollama.com/download
-
ollama run mistral- will download (if not present) and run mistral -
ollama pull mistral- will download but not run the model -
/exit- to exit chat -
ollama list— View downloaded models. -
ollama rm <model_name>— Delete a model to save space. - We can also use one of ollama cloud models so the inference is run on remote server and does not run locally.
Setting Up and Managing a Python Project with Poetry and Jupyter
- Ensure you have Python installed (version 3.9 or later).
- Install Poetry by running:
curl -sSL https://install.python-poetry.org | python3 -Navigate to your project directory:cd path/to/dspy-devInitialize a new Poetry project:
poetry init
poetry add dspy
Install the dependencies and create a virtual environment:
poetry install
poetry add jupyter ipykernel
Create a new Jupyter kernel:
poetry run python -m ipykernel install --user --name dspy-dev --display-name "Python (dspy-dev)"
poetry run jupyter notebook
Top comments (0)