When trying to install the pyserial package on macOS using the command python3 -m pip install -U pyserial
I got error: externally-managed-environment
. Why? macOS’s updated Python environment restrictions (PEP 668), prevent global package installations to protect system-managed Python environments. There are three possible resolutions:
- pipx (detailed below)
- virtual environment - what I did:
python3 -m venv pyserial_env \ source pyserial_env/bin/activate \
python3 -m serial``` - Bypass restrictions - not super advisable, as the new restrictions make sense:
python3 -m pip install pyserial --break-system-packages
I’d recommend updating the tutorial :
Installing Python miniterm on macOS using pipx
A. Install Homebrew (if not already installed):
Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
B. **Install pySerial using pipx:**
```pipx install pyserial```
C. **Install pySerial using pipx:**
```pipx install pyserial```
D. **Run miniterm:**
```python3 -m serial```