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. – Sören Dec 8 '17 at 15:11

software-properties-gtk option "Source code"

I recommend this for the desktop:

software-properties-gtk

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 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 successful 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.

  • 4
    This just worked for me with ubuntu 16.04 – Or Duan Mar 22 '17 at 16:31
  • 2
    Also solved it for me on Ubuntu 18.04 – kramer65 Apr 3 at 18:54
  • 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). – kilgoretrout Nov 7 at 1:38
  • 1
    @kilgoretrout "how is the accepted answer" Because Google search hits beat exact question semantics. – Ciro Santilli 新疆改造中心 六四事件 法轮功 Nov 7 at 5:10

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/

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

Edit /etc/apt/sources.list

sudo nano /etc/apt/sources.list

remove # or add lines deb-src $url . $url = an esisting line

Example

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

deb blah blah

deb-src exact same blah blah

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

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

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

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

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

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

39c9
< 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

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

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

now issue once again your original command which failed with :

E: You must put some 'source' URIs in your sources.list
  • You can skip the cp and use -i~orig with sed to have sed make the backup. – muru Mar 4 at 3:23
  • @muru cool thanks so noted – Scott Stensland Mar 4 at 4:01

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.