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

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 
2

7 Answers

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:

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: go and upvote that answer.

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

# deb bionic partner
# deb-src 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.

9

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

deb-src trusty main restricted #Added by software-properties
deb-src trusty restricted main universe multiverse #Added by software-properties
deb-src trusty-updates restricted main universe multiverse #Added by software-properties
deb-src trusty-backports main restricted universe multiverse #Added by software-properties
deb-src trusty-security restricted main universe multiverse #Added by software-properties
deb-src 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 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:

4

Edit /etc/apt/sources.list

sudo nano /etc/apt/sources.list

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

deb saucy main restricted
deb-src 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 for additional information.

1

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 bionic main restricted
# deb-src bionic-updates main restricted
# deb-src bionic universe
# deb-src bionic-updates universe
# deb-src bionic multiverse
# deb-src bionic-updates multiverse
# deb-src bionic-backports main restricted universe multiverse
# deb-src bionic partner
# deb-src bionic-security main restricted
# deb-src bionic-security universe
# deb-src bionic main universe restricted multiverse
# deb-src 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
2

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 xenial main restricted
---
> # deb-src xenial main restricted
19c19
< deb-src xenial universe
---
> # deb-src xenial universe
39c9
< deb-src xenial-backports main restricted universe multiverse
---
> # deb-src xenial-backports main restricted universe multiverse
53c53
< deb-src xenial-security multiverse
---
> # deb-src 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

You Might Also Like