6

As you know Ubuntu already has python in it. However, I have downloaded the latest 3.5.1 version's source code and compiled it using

./configure
make
make test
sudo make install

My pwd at this moment is /home/SarpSTA/Downloads/Python-3.5.1

I wanted to run purge on this new installation.

sudo apt-get purge python wouldn't do since its path was running the old version not the new installation. So, while still was in the folder, I ran sudo apt-get purge ./python. It created a very long output that was like:

E: Release 'python' for 'package-name' was not found

for every single package I have installed on my computer in place of package-name.

Did I delete something or was the code simply a failure?

3
  • 1
    A bit late now, but if you manually install a program that is also present in apt, you should install it in a different location! Feb 22, 2016 at 11:02
  • 1
    I just want to mention that Python 3.5 is in the repositories of 15.10 and later. You can use a PPA from another amswer that offers many versions of Python for older releases. (Link not included as I'm writing this on a phone.)
    – LiveWireBT
    Feb 23, 2016 at 6:43
  • @LiveWireBT Thank you! I have downgraded back to 14.04 since LTS better suited me. But should I ever go back I'll make use of it.
    – SarpSTA
    Feb 23, 2016 at 7:08

3 Answers 3

15

That's not how it works. You can only use apt-get purge with packages installed by APT or dpkg (Debian .deb packages). If you compiled your software from source APT won't keep track of it.

If you still have your source code folder, cd into it and run sudo make uninstall. This command should delete the compiled software.

If you don't have the source anymore I recommend you to download it again, run ./configure inside it and then sudo make uninstall.

Be very careful not to delete the default Python installation. It's a very important part of Ubuntu and you'll have a broken system if you delete it.

So no, you didn't do any damage by running sudo apt-get purge ./python, because the package couldn't be found.

5
  • Just a comment to soften this: you can re-install python using a normal download of the 3 main python packages and "dpkg". So all is not lost if you do make the mistake to delete python :)
    – Rinzwind
    Feb 20, 2016 at 23:47
  • Thanks! I just thought it was good to put some pressure in it, so newbie dumbness is avoided. Feb 20, 2016 at 23:48
  • 6
    -1 for not really answering the explicit question of having done any damage by running that apt-get purge command. Feb 21, 2016 at 4:35
  • Yeah I ran the sudo apt-get purge python too but after checking the list of packages it deletes with itself I stepped back. But as @mgarciaisaia pointed out the answer misses the actual part. What did I do on my computer by running the command sudo apt-get purge ./python ?
    – SarpSTA
    Feb 21, 2016 at 10:16
  • Nothing. The command did not succeed because the package was not found. Feb 21, 2016 at 13:02
7

No. That command didn't do any damage. It didn't do anything but give you the error message indicating that it couldn't perform the task.

As far as trying to purge the installed version, you don't have to purge it, just make a symbolic link to the installed version that you want for your default. Of course you could also alternatively call python by the full pathname of the installed version.

Example:

$ /usr/bin/python3.7 myprogram.py

The proper command for uninstalling would be to give the package name as the remove parameter.

Example for removing a package:

$ sudo apt-get remove python

You can tell the current symbolic link on your system by running:

$ ls -l /usr/bin/python*

The above command will also show you other versions that happen to be installed.

Of course many programs use the shebang (#!) to specify the program interpreter to run. You can see an example of this by running this command:

$ egrep python * | egrep "/usr/bin/python"

The output of the above command will show you the name of various python applications with the specified version to run. The program and command to run is separated a colon in the list.

7

To understand what apt-get purge ./python tried to do, let's follow the manpage. First, the general syntax:

apt-get [-asqdyfmubV] [-o=config_string] [-c=config_file]
        [-t=target_release] [-a=architecture] {update | upgrade |
        dselect-upgrade | dist-upgrade |
        install pkg [{=pkg_version_number | /target_release}]...  |
        remove pkg...  | purge pkg...  |
        source pkg [{=pkg_version_number | /target_release}]...  |

You'll see that apt-get supports specifying a target release via /foo. So, in ./python, apt-get interpreted python as a target release. We'll get back to this in a moment.

Now, what about .? apt-get supports regular expressions, and if the package name contains ., *, etc., it will treat it as a regular expression. And apt-get checks for partial matches - as long as the given expression matches a part of a package name, that package is selected:

If no package matches the given expression and the expression
contains one of '.', '?' or '*' then it is assumed to be a POSIX
regular expression, and it is applied to all package names in the
database. Any matches are then installed (or removed). Note that
matching is done by substring so 'lo.*' matches 'how-lo' and
'lowest'. If this is undesired, anchor the regular expression with
a '^' or '$' character, or create a more specific regular
expression.

. matches every character - so every package name will satisfy it. Therefore, apt-get will select every package it knows of.

Now, back to the target release, it is used for specifying which repository you want to target for this operation, if the same package is provided by multiple repositories. See How to only install updates from a specific repository?

python is not a valid release on default Ubuntu (and unlikely to be one anyway). So, even though apt-get picked every package it knew of, it couldn't find a matching release, and therefore, failed.

You must log in to answer this question.

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