I am getting syntax error with '%%capture'



# Connecting to the factbook database
%load_ext sql
%sql sqlite:///factbook.db

What I expected to happen:
‘Connected: [email protected]

What actually happened:

File "<ipython-input-3-2472a1c0fcad>", line 2
SyntaxError: invalid syntax

For some reason, even though I copied the code as it was written, I am getting a syntax error.

!python -i


Python 2.7.6 (default, Nov 13 2018, 12:45:42) 
[GCC 4.8.4] on linux2
1 Like

Have you tried running it without the comment above it?

1 Like

Yes, I have.
I still get syntax error.

As I try to run it again now, it is stuck running ( [ * ] ), no output at all.
Perhaps the server is down? Or experiencing issues?

Maybe try restarting the kernel and rerunning the cell (make sure the comment is gone). I get an error when I have a comment before the %%capture line but it runs fine when I erased it.


Thank you april, restarting the kernel and rerunning every cell, after removing the comment, makes it run.


1 Like