1

I'm trying to use the line magic %lprun in jupyter notebook running a python 2.7.5 kernel.

The code I'm trying to run is the following:

%load_ext line_profiler
distance = 20
veg_slope = 0
slope = 10
%lprun test = bal.run('forest', veg_slope, slope, distance, FFDI=100)

The bal.run code is a bit complicated, but executing the code with those parameters will output the following tuple:

(35.02405579440225, 'BAL-40')

However if I try to use the %lprun magic I get the following error:

File "<string>", line 1
test = bal.run(\'forest\', veg_slope, slope, distance, FFDI=100)
                                                                ^
SyntaxError: unexpected character after line continuation character

Not sure what is happening there, but as a test I tried to run a simple python function like print together with the line_profiler, and that worked.

Anyone has any idea of what the problem could be?

Alessio Arena
  • 390
  • 2
  • 8

2 Answers2

0

I have just had the same issue in Jupyter / Python 3.6 using example code from a presentation available here.

I'm still a newbie but the traceback ends with the same syntax error:

File "", line 1 df[\'high_rate_normalized\'] = normalize(df, df[\'high_rate\']) ^ SyntaxError: unexpected character after line continuation character

Rumit Patel
  • 8,830
  • 18
  • 51
  • 70
JedB
  • 463
  • 4
  • 7
0

Change to double quotes "

%lprun test = bal.run("forest", veg_slope, slope, distance, FFDI=100)
pls256
  • 66
  • 5