In Ubuntu 14.04, I've set python3.4 as the default python version. After that, Dropbox doesn't launch at startup and the Ubuntu Software Center cannot open up anymore. Running them from the command line, I have:

petrux@MYMACHINE:~$ dropbox 
  File "/usr/bin/dropbox", line 232
    except OSError, e:
SyntaxError: invalid syntax

petrux@orion:~$ software-center
  File "/usr/bin/software-center", line 140
    print time.time()
SyntaxError: invalid syntax

How can I work around this problem?

EDIT: I just noticed that, in addition, there is no audio output any more.

  • We need log, try to launch dropbox from terminal with dropbox and give us the log. – rɑːdʒɑ Dec 16 '14 at 11:17
  • @AgentCool I edited the question adding the dumps. I'm pretty sure they're python version related issues. Thanks. – petrux Dec 16 '14 at 11:22
  • This is due to switching Python version only. If you dont use python3 then switch it to Python2 else tell us purpose of switching to python3 . so we will try to help – rɑːdʒɑ Dec 16 '14 at 11:24
  • I want to switch to python3 as I'm using a library which is avialable only for python3. – petrux Dec 16 '14 at 11:26
  • You still have a choice , for example its a python script/program and need python3 environment then by using #!/usr/bin/env python3 you can set like your program have to use python3 environment. and you can keep 2.7 as default environment of yours – rɑːdʒɑ Dec 16 '14 at 11:30

If this is the problem you are getting.

File "/usr/bin/dropbox", line 215
    except OSError, e:
SyntaxError: invalid syntax

It may be due to update of your python from python2 to python3 and setting python3 as default python. to get rid of of this problem you can follow the below steps.

Tyr the below steps,

  1. Open cd /usr/bin/dropbox file and in the edit mode.
  2. Change the first line from #!/usr/bin/python to #!/usr/bin/python2
  3. Restart the dropbox app and it should work good.
| improve this answer | |
  • This fixed it for me. – David Powell Jul 21 '19 at 22:10

The generic command python and shebang #!/usr/bin/python currently map to Python 2. Do NOT change that mapping yourself - it will break many essential system applications and services in 14.04 that still use Python 2, and won't work with Python 3 yet.

Undo whatever you did to set Python 3.4 as the default python version.

Both Python 2 and Python 3 are included with 14.04. Applications and services on your system may rely on either.

To launch the Python 3 interpreter, use the command python3 or put a shebang #!/usr/bin/python3 in your script.

To launch the Python 2 interpreter, use the command python or python2, or put the shebang #!/usr/bin/python or #!/usr/bin/python2 in your script.

| improve this answer | |

for me, I set default python to 3 using the following command sudo update-alternatives --config python

changing it back to python 2 solves the problem

| improve this answer | |

If you don't have update-alternatives already configured, a good practice would be list all python installations in order to switch between them quickly

First add all python versions installed (can be seen executing ls /usr/bin/python*) with the following command:

sudo update-alternatives --install /usr/bin/python python <path-to-python-version> <priority>

Example (to solve this problem with Dropbox, add python 2.7 to be listed on the alternatives)

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 3

Execute sudo update-alternatives --config python to list all added alternatives and choose python version typing the respective Selection value.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.