Python: [Errno 30] Read-only file system

When you are developing a new python application, you are likely working with pip to get an initial set of packages installed. If you have conflicting packages already installed in your profile, pip might throw an error similar to this:

ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '/gnu/s                                                                                                           tore/76sq54dz5yb4qajzg8p02s2kzzwgq8cn-python-3.8.2/lib/python3.8/site-packages/certifi-2021.5.30.dist-i                                                                                                           nfo' 

Here’s how you work around this issue:

  1. Create a new, pure guix environment with only python available
guix environment \
--pure python \
--ad-hoc python
  1. Create a pip virtual environment within the environment:
python3 -m venv venv
source venv/bin/activate
  1. Install your package dependencies:
pip3 install .

That’s all! The best thing is, this environment only contains packages that you specifically install during the current session. All your system packages (even python ones) are excluded and won’t interfere.

To close the environment:

deactivate # exit python venv
exit # exit guix virtual environment

Now you’re back on your normal shell.