Search code examples
pythonpython-3.xpip

pip3 tries to write to /var/log even with venv and failing


I follow these steps, and they always fail.

mkdir python-mess
cd python-mess
echo toml > requirements.txt
which python3
# /usr/bin/python3
which pip3
# /usr/bin/pip3
python3 -m venv .venv
source .venv/bin/activate
# (.venv is added to prompt)
which pip3
# /home/karel.bilek/python-mess/.venv/bin/pip3
which python3
# /home/karel.bilek/python-mess/.venv/bin/python3
pip3 install -r requirements.txt

The last step always fails, with

PermissionError: [Errno 13] Permission denied: '/var/log/python_pip.log'

WHY? What else to do?

I am using Debian Bookworm, plain python 3, plain bash. I am not installing something weird, just toml package! There is nothing else in the folder except for requirements.txt.


Solution

  • It seems the issue was global /etc/pip.conf that had

    [global]
    log-file = /var/log/python_pip.log
    

    I solved it by doing

    mkdir -p ~/.pip
    echo "[global]" > ~/.pip/pip.conf
    echo "log = ~/.pip/pip.log" >> ~/.pip/pip.conf