Did I do any damage by running "sudo apt-get purge ./python"?
Solution 1:
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.
Solution 2:
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.
Solution 3:
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.