Ubuntu: Syntax error on python 2.7.3



Question:

I am trying to perform a QSTK related task on python2.7.3 but ending up with syntax error

[Python 2.7.3 (default, Sep 26 2012, 21:51:14)   [GCC 4.7.2] on linux2  Type "copyright", "credits" or "license()" for more information.  >>> python tutorial1.py  SyntaxError: invalid syntax  >>> ],  

I went through a whole tutorial to setup python & other prerequisite softwares, everything got installed perfectly except for the following

@ubuntu:~$ sudo apt-get build-dep python-cvxopt  Reading package lists... Done  Building dependency tree         Reading state information... Done  E: You must put some 'source' URIs in your sources.list  

Is this installation incomplete?
Is the problem on Python related to this incomplete installation?

How can i sort out this installation & syntax error problem?


Solution:1

Well, your original problem which mainfests in a SyntaxError exception is a funny one: you started a python interpreter and then trying to run a shell command from there. This won't work. You need to exit the Python interpreter (with Ctrl-D) and execute your file from the shell prompt. The actual command will be the same:

python tutorial1.py  

(provided that your current directory contains tutorial1.py file)

If you need cvxopt module installed in Python, you can do that with

sudo apt-get install python-cvxopt  

You don't need to use build-dep command. Also, I'd suggest to try running a simple "Hello, World" script first which doesn't depend on complex third-party stuff and only then proceed to trying to use cvxopt.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »