I am getting syntax error with '%%capture'

https://app.dataquest.io/m/257/guided-project%3A-analyzing-cia-factbook-data-using-sql/1/introduction

Code:

# Connecting to the factbook database
%%capture
%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
    %%capture
    ^
SyntaxError: invalid syntax

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

!python -i

yields:

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.

2 Likes

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

:hugs:

1 Like