How to solve the error: WARNING:root:could not open file '/etc/apt/sources.list'

Changing the permissions might work:

sudo chmod -R 0644 /etc/apt/sources.list.d/

UPDATE: I previously set the mode to 0420, which worked in my case, but per comments and further testing it seems that 0644 is correct.


The sources.list files are in /etc/apt/sources.list.d in newer version of Ubuntu. So you need to make a symbolic link from official-package-repositories.list to the old place to solve this problem:

sudo ln -s /etc/apt/sources.list.d/official-package-repositories.list /etc/apt/sources.list