I'm trying to install PIL a python module on ubuntu

I first need to install a package called python-imaging using the following command

sudo apt-get build-dep python-imaging

When I try and do this I get the error

E: You must put some 'source' URIs in your sources.list

I saw this question whihc shows how to fix via the GUI but I'm using the command line. Does anyone know how I can fix this error..?

UPDATE: Based on the below answers I've updated my package list but I now get this error. Not sure if it is related, if not I'll start a new question as I can't find reference to the error anywhere.

E: Build-Depends dependency for python-imaging cannot be satisfied because candidate version of package python-all-dev can't satisfy version requirements  
  • The first error message is quite confusing. It shows up although there are SOME sources in the file while the message implies that there are no sources at all. What the message tries to say is you have to ADD a source that contains the info.
    – Soerendip
    Dec 8, 2017 at 15:11
  • 1
    after adding deb-src lines in sources.list I had to apt update to get this message to go away
    – teknopaul
    May 23, 2021 at 15:30

8 Answers 8


software-properties-gtk option "Source code"

I recommend this for the desktop:


then under the "Ubuntu Software" tab click "Source code":

enter image description here

This has added some deb-src lines under /etc/apt/sources.list, and now I can do sudo apt-get build-dep <package>.

I've couldn't find a clean CLI method so I create this bug report for it: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1802718

Tested on Ubuntu 16.04 to 18.04.

CLI method

I recommend this for Docker images:

sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update

Tested on the Ubuntu 18.04 Docker image. After this change, I can successfully do for example:

sudo apt-get build-dep hello

and before the change it failed with the error:

E: You must put some 'source' URIs in your sources.list

Previously mentioned at: https://askubuntu.com/a/1011675/52975 go and upvote that answer.

Note however that the /etc/apt/sources.list file contains lines such as:

# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

which means that the above sed would enable sources but not non-sources for some types of repos. I don't think that it matters much though.

  • 7
    This just worked for me with ubuntu 16.04
    – Or Duan
    Mar 22, 2017 at 16:31
  • 3
    Also solved it for me on Ubuntu 18.04
    – kramer65
    Apr 3, 2018 at 18:54
  • 1
    how is the accepted answer "I know you asked no GUI but sometimes devs just don't support it properly" - this is not helpful when you have no GUI (e.g., Docker). Nov 7, 2018 at 1:38
  • 2
    @kilgoretrout "how is the accepted answer" Because Google search hits beat exact question semantics. Nov 7, 2018 at 5:10
  • 2
    working in 20.04
    – Heisenberg
    Nov 7, 2020 at 11:34

You can edit the source list (/etc/apt/sources.list) directly. I think you need to add in/uncomment these lines:

deb-src http://archive.ubuntu.com/ubuntu trusty main restricted #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty-updates restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse #Added by software-properties
deb-src http://security.ubuntu.com/ubuntu trusty-security restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ trusty-proposed restricted main universe multiverse #Added by software-properties

I worked this out by disabling the source code option, and saving one copy of the sources.list file, then enabling the source code option, saving another copy, then running diff on both.

You may want to change the prefix http://gb. to the prefix of the other sources in your list (so it uses your nearest repo mirror), and you can also ignore the #Added by software-properties.

After editing sources.list, run sudo apt-get update before trying to install again.

The full diff can be found here

Another way is to generate a new one. One method to get a complete sources.list is to use this site:https://repogen.simplylinux.ch/

  • 8
    "After editing sources.list, run sudo apt-get update before trying to install again." -- That was the key, thanks! Nov 17, 2017 at 19:34
  • 11
    sudo sed -i -e 's/# deb-src/deb-src/' /etc/apt/sources.list
    – Vincent
    Dec 22, 2017 at 15:09
  • 1
    thanks pal for remember me that $ sudo apt update Mar 12, 2018 at 5:11
  • 1
    @Vincent's comment was enough for me and super clean Nov 7, 2018 at 1:41

Edit /etc/apt/sources.list

sudo nano /etc/apt/sources.list

Then remove # or add lines with deb-src $url, for example:

deb http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted
deb-src http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted

Or copy from the existing lines, e.g.

deb blah blah
deb-src exact same blah blah

Then run:

sudo apt-get update

See https://help.ubuntu.com/community/Repositories/CommandLine for additional information.

  • 18
    exec sudo apt-get update after editing the sources.list file
    – abidibo
    Mar 18, 2015 at 11:57

Here is the command line solution

cat /etc/apt/sources.list | grep deb-src  #  see what will get changed

typical output of above cmd

# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://archive.canonical.com/ubuntu bionic partner
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://archive.ubuntu.com/ubuntu bionic main universe restricted multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

if you are good changing above lines, which is always true on a fresh ubuntu install, then issue :

sudo sed -i~orig -e 's/# deb-src/deb-src/' /etc/apt/sources.list   

which does a backup of input file, then a search for commented out deb-src where it removes the comment to make those lines active ... following refresh of local metadata will give your machine awareness of new catagories of ubuntu packages

sudo apt-get update  #  refresh of local metadata

now issue once again your original command which failed with :

E: You must put some 'source' URIs in your sources.list
  • 2
    You can skip the cp and use -i~orig with sed to have sed make the backup.
    – muru
    Mar 4, 2018 at 3:23
  • 1
    This is my favorite answer because it shows what will be changed first, then command line to do the change.
    – wisbucky
    Aug 3, 2020 at 18:32

For Ubuntu 16.04, I successfully made these updates to sources.list :

$ sudo diff /etc/apt/sources.list /etc/apt/sources.list.bkp 

< deb-src http://au.archive.ubuntu.com/ubuntu/ xenial main restricted
> # deb-src http://au.archive.ubuntu.com/ubuntu/ xenial main restricted

< deb-src http://au.archive.ubuntu.com/ubuntu/ xenial universe
> # deb-src http://au.archive.ubuntu.com/ubuntu/ xenial universe

< deb-src http://au.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
> # deb-src http://au.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

< deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
> # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

In Linux Mint (I am on version 18) you can go to Software Sources (search for it in the start menu or open it from a terminal with software-sources). There, on the first tab, you will find a checkbox Enable source code repositories. If you enable this the program will put the correct lines into your /etc/apt/sources.list.d/official-source-repositories.list file. Just don't forget to sudo apt-get update (or hit Update the cache in the Software Sources) after that.


My solution takes the already configured deb lines and adds them as deb-src ones. Tested using the perl:5.28 docker image which builds upon buildpack-deps:buster which builds upon debian:buster:

sudo su -
grep '^deb ' /etc/apt/sources.list | perl -pe 's/deb /deb-src /' >> /etc/apt/sources.list
  • This is great as it works in Debian docker images. Initially I thought that using perl might be an overkill but it seems perl is already included in the docker image so it's fine. The sed equivalent would be almost identical: grep '^deb ' /etc/apt/sources.list | sed -e 's/^deb /deb-src /' >> /etc/apt/sources.list
    – Emsi
    Feb 20, 2023 at 14:13

Remove “#” from all lines starting with deb-src from the /etc/apt/sources.list but create a backup first. Then update.

Just run these commands:

sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt update

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .