Home/Guides/How to set up Python with uv or pyenv on a remote Mac mini

How to set up Python with uv or pyenv on a remote Mac mini

Updated · airankrush

What this guide covers

When you finish, each project has its own Python version and virtual environment, and the system Python is untouched. You need: the command line tools, plus Homebrew if you install that way.

Steps

  1. Look at the system Python, but do not use it

    /usr/bin/python3 belongs to the system and the command line tools. System updates replace it, so installing packages into it is unstable and hard to clean up. This matters even more on a rented machine: keep the system as close as you can to the state the platform delivered it in, and put your whole environment inside your own user directory. At the end of the rental, deleting one directory leaves it clean.

  2. Option 1: install uv

    Following the official uv installation docs, choose one of two ways:

    curl -LsSf https://astral.sh/uv/install.sh | sh

    or brew install uv. The standalone install script puts the program in your user directory, and you upgrade it later with uv self update. A Homebrew install follows brew upgrade instead; the docs state that uv self update only works for the standalone install. Neither way needs an administrator password.

  3. Install an interpreter and create a virtual environment with uv

    uv python install installs the latest Python, and uv python list shows available and installed versions. Inside the project directory, uv venv creates a virtual environment (and downloads an interpreter first if there is none). To see where interpreters and the cache are stored, run uv python dir and uv cache dir. You will need these later when freeing disk space.

  4. Option 2: install pyenv

    Following the official pyenv README: run brew update, then brew install pyenv, then write these three lines into ~/.zshrc:

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
    echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc

    pyenv compiles Python on the machine, and the project requires the build dependencies to be installed first. The list is under "Suggested build environment" in its wiki. After that, pyenv install <version> installs a version, pyenv global <version> sets the default, and pyenv local <version> inside a project directory sets the project version.

  5. Run builds and downloads in a session that survives a disconnect

    Compiling a version with pyenv, or installing a large set of dependencies for a model project, takes a while. Disconnecting the remote desktop does not stop it, but closing the terminal window does. Run these commands inside a tmux session and reattach later to see the result. See keeping long tasks running.

  6. Give unattended scripts the interpreter path inside the virtual environment

    Scheduled jobs and jobs that start at login will not activate a virtual environment for you. The most reliable approach is to use the full path of the interpreter in the job config, for example .venv/bin/python script.py under the project directory. That does not depend on source activate or on the initialization in ~/.zshrc.

  7. Lock dependencies into the repository; the environment itself needs no backup

    Virtual environments and interpreters can be rebuilt at any time and are not worth backing up. What is worth taking with you is the dependency list (pyproject.toml, a lock file or requirements.txt) and .python-version. Once those are committed to your own repository, switching machines or ending the rental only means installing again. When disk space is tight, uv cache clean clears the uv cache.

FAQ

Should I install both uv and pyenv?

No need. uv can download and manage interpreters by itself. Choose pyenv when an existing project depends on a pyenv workflow. If you do install both, watch the PATH order and confirm which one is in use with which python3.

What about Python libraries that have a graphical interface or need system permissions?

Libraries that involve permissions such as Screen & System Audio Recording or Accessibility need you to open System Settings in the remote desktop and grant access to the terminal or the relevant app when prompted. See screen control permissions.

The Python dependencies for running models are large and the disk is full. What can I do?

Clear caches and unused virtual environments first. Built-in storage cannot be increased during the rental term. If you need external storage, check with support first to arrange it. For configuration choices, see the plans page.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All guides