30

I often find myself wanting to install something, but I'm unsure of what package it's in. This is a very common occurrence for me:

$ make html
sphinx-build -b djangohtml -d _build/doctrees   . _build/html
make: sphinx-build: Command not found
make: *** [html] Error 127

$ sudo apt-get install sphinx
E: Unable to locate package sphinx

$ sudo apt-get install sphinx-build
E: Unable to locate package sphinx-build

googles

$ sudo apt-get install python-sphinx

Is there a better way?

6 Answers 6

32

Install apt-file and run apt-file update

Then use apt-file search sphinx-build to search for packages contanining a file named sphinx-build

1
  • Nice one! I have always resorted to packages.ubuntu.com, but a command line app is always best :D
    – Egil
    Apr 12, 2011 at 15:16
15

Ubuntu is pretty smart. Just try to run it.

$ sphinx-build

The program 'sphinx-build' is currently not installed.  You can install it by typing:
sudo apt-get install python-sphinx
3
  • 2
    Does anyone know exactly how this "smartness" is implemented in Ubuntu? e.g., which package provides this?
    – entropo
    Apr 12, 2011 at 22:12
  • 5
    @entropo: The package that provides this functionality is "command-not-found".
    – Tweek
    Apr 12, 2011 at 23:52
  • 3
    This should be used very carefully as a command that doesn't work from a script or makefile may work if called from your shell (e.g. because the script is using another $PATH or you have a alias with the same name in your shell) and could have undesired effects. Apr 13, 2011 at 17:08
3

I don't know if apt-get can do it, but I prefer to use aptitude anyway.

Using its search command, you get a list of packages that contains the string you are searching for, however that still does not fully answer your question, as it does not reveal which package contains the binary you are looking for.

Example:

sudo aptitude search sphinx
p   gstreamer0.10-pocketsphinx      - lightweight speech recognition - GStreamer
p   libpocketsphinx-dev             - lightweight speech recognition - developme
p   libpocketsphinx1                - lightweight speech recognition - library  
p   libsphinx-search-perl           - Perl module for Sphinx search engine      
p   libsphinx2-dev                  - speech recognition library - development k
p   libsphinx2g0                    - speech recognition library                
p   libsphinxbase-dev               - Sphinx base libraries - development files 
p   libsphinxbase1                  - Sphinx base libraries                     
p   pocketsphinx-hmm-tidigits       - lightweight speech recognition - TIDIGITS 
p   pocketsphinx-hmm-wsj1           - lightweight speech recognition - WSJ1 acou
p   pocketsphinx-lm-wsj             - lightweight speech recognition - WSJ langu
p   pocketsphinx-utils              - lightweight speech recognition - command-l
p   python-pocketsphinx             - lightweight speech recognition - Python mo
p   python-pocketsphinx-dbg         - lightweight speech recognition - Python mo
p   python-repoze.sphinx.autointerf - Sphinx extension that auto-generates API d
p   python-sphinx                   - tool for producing documentation for Pytho
p   python-sphinxbase               - Sphinx base libraries - Python module     
p   python-sphinxbase-dbg           - Sphinx base libraries - Python module (deb
v   python2.6-pocketsphinx          -                                           
v   python2.6-pocketsphinx-dbg      -                                           
v   python2.6-sphinxbase            -                                           
v   python2.6-sphinxbase-dbg        -                                           
v   python2.7-pocketsphinx          -                                           
v   python2.7-pocketsphinx-dbg      -                                           
v   python2.7-sphinxbase            -                                           
v   python2.7-sphinxbase-dbg        -                                           
p   sphinx2-bin                     - speech recognition utilities              
p   sphinx2-hmm-6k                  - speech recognition library - default acous
p   sphinxbase-utils                - Sphinx base libraries - utilities         
p   sphinxsearch                    - Fast standalone full-text SQL search engine
1
  • This helps somewhat, but after that you would need to run something like 'dpkg -L packagename | grep bin' to find what commands a package actually provides.
    – Tanath
    Apr 12, 2011 at 20:41
3

I like to use http://packages.ubuntu.com/ -- there's "Search the contents of packages" inside. Debian also has similar interface at http://packages.debian.org.

This has the advantage that you can use it without CLI access to Ubuntu itself, f.e. explaining things over a phone.

1

you can use the apt group of commands or aptitude which i recommend above apt. Here is the list to search

APT

To search for something similar to the command you want: apt-cache search X for example apt-cache search cheese will give you everything related to cheese.
To show what dependencies and stuff it has you would do apt-cache show cheese.
Of course to install would be apt-get install cheese.

APTITUDE

To search: aptitude search cheese which will show a more nicer list than apt
To show: aptitude show cheese which again will show a more nicer and friendlier list
To install: aptitude install cheese to install it. Again nicer.

Also aptitude gives more relevant information to what you are looking for, for example:

apt-cache search phi VS aptitude search phi
apt-cache search sphi VS aptitude search sphi

If you want a GUI version i recommend Synaptic Package Manager or a simpler Software Center. In Synaptic you can look for something similar to what you are looking for and it will show it to you.

0

auto-apt

auto-apt is a package that comes in handy a lot, especially with Makefiles and configure scripts that reference things you might not have and don't know where to find, which is often tricky with header files. You invoked make in this case, and it tried to invoke sphinx-build, but failed when it couldn't find it.

auto-apt run [...] will run the command specified, then guide you through installing packages containing missing files that it knows apt-get can find and install.

So, just invoke auto-apt run make html and see what happens :)

For more information, see the the documentation for auto-apt

You must log in to answer this question.

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