Stylish mechanical keyboard with colorful keycaps on wood desk, vibrant workspace.

Python and Node in iSH: What Runs Well on an iPhone

The goal: scripting on your iPhone, with realistic expectations

iSH runs Alpine Linux by emulating a 32-bit x86 CPU on your phone’s ARM chip, as I explained in my guide to running a Linux shell on iPhone with iSH. That means you can install genuine Python and Node.js, not ports. It also means everything runs through an interpreter that is itself being emulated. This post sets up Python and Node in iSH and is honest about what is pleasant and what isn’t.

Installing Python

Python 3 and pip come from Alpine’s repositories (see installing packages in iSH with apk if apk is new to you):

apk update
apk add python3 py3-pip
python3 --version

The App Store build of iSH uses an Alpine 3.14 snapshot, so the Python version is older than current releases. Check the version before relying on newer syntax.

Use a virtual environment

Keep project packages out of the system Python:

python3 -m venv ~/venvs/tools
. ~/venvs/tools/bin/activate
pip install requests

This matters even more if you’re on a TestFlight build with a newer Alpine base: recent Alpine releases mark the system Python as externally managed, and pip install outside a venv will refuse to run.

Prefer Alpine packages for compiled libraries

pip works, but the iSH wiki describes it as very slow, and anything that needs compiling (C extensions) takes far longer again. Where Alpine packages a library, install that instead:

apk search py3-        # browse packaged Python libraries
apk add py3-yaml

Installing Node.js

Node and npm are separate packages in Alpine:

apk add nodejs npm
node --version
npm --version

Again, expect an older release from the 3.14 snapshot. Check the version before installing tools that require a recent Node; many current CLI tools won’t support it. Install packages locally per project rather than globally:

mkdir ~/scratch && cd ~/scratch
npm init -y
npm install dayjs

What runs well

  • Short Python scripts: text processing, renaming files, parsing CSV or JSON, hitting an API with requests or urllib.
  • Small Node scripts with few dependencies.
  • The Python REPL as a calculator and quick test bench.
  • Simple local servers for testing, such as python3 -m http.server 8000, which you can open in Safari at http://localhost:8000 while iSH stays active.

What’s slow or impractical

  • Big npm installs: projects with hundreds of dependencies take a long time to install and use a lot of storage. Front-end build chains are a poor fit.
  • Compiling native modules: node-gyp builds and pip packages with C extensions need build-base and a lot of patience.
  • Number crunching: heavy numeric work suffers most from emulation overhead.
  • Prebuilt binaries: anything that downloads a 64-bit or ARM binary during install won’t run, because iSH only executes 32-bit x86 code.
  • Long jobs: iOS suspends iSH when you leave it, so long tasks pause. Run them in tmux and keep the app in the foreground.

Troubleshooting

  • pip seems frozen: it’s probably compiling. Check whether an Alpine py3- package exists instead.
  • "Illegal instruction": a dependency uses CPU instructions iSH doesn’t emulate. Try an older version of that package or a pure-Python or pure-JavaScript alternative.
  • "Unsupported engine" from npm: the package needs a newer Node than the snapshot provides. Pin an older version of the package.
  • Running out of space: clear npm’s cache with npm cache clean --force and delete unused venvs.

If you mainly want Python on your phone and don’t need a full Linux userland, a-Shell runs Python natively and is much faster. I compare them in iSH vs a-Shell vs Blink Shell.

Wrapping up

Python and Node in iSH are real, useful and slow. Treat them as tools for small scripts and quick experiments rather than a development environment, lean on Alpine’s prebuilt packages, and use virtual environments and per-project installs to keep things tidy. Within those limits, having a proper interpreter in your pocket is surprisingly handy.

iSH: Linux on your iPhone series. Start with the original guide to running a Linux shell on iPhone with iSH, then:

  1. Installing packages in iSH with apk
  2. SSH and git on iPhone with iSH
  3. Python and Node in iSH
  4. iSH vs a-Shell vs Blink Shell
  5. Accessing iOS files in iSH

Leave a Reply