0

Whenever I try to do something like sudo add-apt-repository ... It gives me the following error message:

File "/usr/bin/add-apt-repository", line 37
    print _("The %s named '%s' has no PPA named '%s'" 
          ^
SyntaxError: invalid syntax

This is really frustrating, as I cannot add ANY PPAs.

Sergey
  • 133
  • 3
    As the error says "syntax error", did you try correcting it? I mean 'sudo gedit /usr/bin/add-apt-repository' and editing the line 37 to this: print (_("The %s named '%s' has no PPA named '%s'")) . instead of this : print _("The %s named '%s' has no PPA named '%s'" – Severus Tux Jan 30 '16 at 08:48
  • 1
    I am not sure about this. I just guessed it as it was giving "syntax error". Please wait for someone with better knowledge answers this. (Or try it at your own risk :P) – Severus Tux Jan 30 '16 at 08:50
  • Severus Tux is right. There is a syntax error. Must be print (_(... You can change with sudo gedit or equivalent, or via GUI. I you need more help just let us know. I wonder how that happened in the first place! –  Jan 30 '16 at 08:54

2 Answers2

2

There is a syntax error in the add-apt-repository file.

Open a terminal and execute :

sudo apt-get update  
sudo apt-get install gksu  
gksudo gedit /usr/bin/add-apt-repository  

Add ( to the beginning and )) at the end of the command

print _("The %s named '%s' has no PPA named '%s'"  

... so that the print command afterwards correctly reads ->

print(_("The %s named '%s' has no PPA named '%s'"))  

Save the file - now you should be able to add repositories.

Note : Here is the the link to the PPA you want to add ->
https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa

There you can see, that the command in the Java 8 answer
sudo add-apt-repository ppa:openjdk-r/ppa is correct.

cl-netbox
  • 31,163
  • 7
  • 94
  • 131
  • 2
    having open brackets and without corresponding close brackets is the key here - you need the close brackets in the answer. Point the OP towards launchpad is more important - changing a system file points to a more important bug that needs to be patched. BTW ("...") is valid python2 syntax - (("...")) is python3 (also backward compatible with python2) – fossfreedom Jan 30 '16 at 11:22
  • @cl-netbox Thanks, this helped. But now another problem has risen: when I run it, it says that there is an error at os.umask(0022): Invalid token. What does this mean, and how canI fix it? – Sergey Feb 04 '17 at 21:04
  • @cl-netbox Also, when I tried to comment out the line (to see what happens), it gave me yet an ImportError: No module named softwareproperties – Sergey Feb 04 '17 at 21:14
  • @SergeyIchtchenko Check whether software-properties-common is installed with : apt-cache policy software-properties-common If the package is not installed, execute : sudo apt-get install software-properties-common Now add a repository : sudo add-apt-repository ppa:<ppa-name> Afterwards update the software sources by running : sudo apt-get update – cl-netbox Feb 05 '17 at 10:37
  • @cl-netbox Sorry, didn't help. Any other ideas? I was told that maybe updating my OS to a newer version might help. – Sergey Feb 05 '17 at 18:13
  • @SergeyIchtchenko Then follow exactly this suggestion ... Ubuntu 12.04 will not be supported after April this year any longer ... but do not upgrade - better perform a clean installation ... this OS is way too old ! :) – cl-netbox Feb 05 '17 at 18:17
  • @cl-netbox Alright. By "clean installation" do you mean removing all files and installing a new version, or keeping them and reinstalling the OS? – Sergey Feb 05 '17 at 18:31
  • @SergeyIchtchenko I mean backup your personal stuff and install the new system (Ubuntu 16.04 LTS or Ubuntu 16.10) completely from scratch and then restore the personal files or place them on a separate partition. :) – cl-netbox Feb 05 '17 at 18:46
  • @cl-netbox Thanks for all that help. Turns out that the problem was in my default python version (the /usr/bin/python symlink pointing to python3 and not python2) and I managed to fix it. Thanks again. – Sergey Feb 06 '17 at 15:01
0

Turns out my python version was by default 3.x instead of 2.x, that caused all the problems. I fixed it like this.

Sergey
  • 133