I’m a beginner here so might be missing something, but I’ve noticed that when I try to include a file that has a bug in it (into a Jupyter notebook), the traceback details are not that helpful because they don’t show the line number on the included file where the error occurred.
Example (file “CartPoleBTEnv.jl” has a syntax error on line 165):
Code in Jupyter cell:
include("CartPoleBTEnv.jl")
Cell output:
syntax: extra token "not" after end of expression
Stacktrace:
[1] include at ./boot.jl:326 [inlined]
[2] include_relative(::Module, ::String) at ./loading.jl:1038
[3] include(::Module, ::String) at ./sysimg.jl:29
[4] include(::String) at ./client.jl:403
[5] top-level scope at In[1]:1
Here is the traceback detail if I run the offending file from the command line:
ERROR: LoadError: syntax: extra token "not" after end of expression
Stacktrace:
[1] include at ./boot.jl:326 [inlined]
[2] include_relative(::Module, ::String) at ./loading.jl:1038
[3] include(::Module, ::String) at ./sysimg.jl:29
[4] exec_options(::Base.JLOptions) at ./client.jl:267
[5] _start() at ./client.jl:436
in expression starting at /Users/billtubbs/cartpole/CartPoleBTEnv.jl:165
I tried it and I wasn’t able to reproduce your finding.
I get (near) exactly the same error in a jupyter notebook as in a plain REPL.
Julia 1.4.1, Windows 10, IJulia and Conda/Jupyter latest version/newly installed here.
I’ll try updating my Julia. I only installed it yesterday using conda install -c conda-forge julia and it gave me 1.1.1. I will see if I can find a more recent version.
Here is the console output:
(julia) Bills-Mac-mini-2:cartpole billtubbs$ julia test_error.jl
ERROR: LoadError: syntax: extra token "not" after end of expression
Stacktrace:
[1] include at ./boot.jl:326 [inlined]
[2] include_relative(::Module, ::String) at ./loading.jl:1038
[3] include(::Module, ::String) at ./sysimg.jl:29
[4] exec_options(::Base.JLOptions) at ./client.jl:267
[5] _start() at ./client.jl:436
in expression starting at /Users/billtubbs/cartpole/test_error.jl:2
(julia) Bills-Mac-mini-2:cartpole billtubbs$ which julia
/anaconda3/envs/julia/bin/julia
Note: All that is missing from the Jupyter output is the last line:
in expression starting at /Users/billtubbs/cartpole/test_error.jl:2
Can you confirm you see that in your Jupyter notebook?
Other than that could it be a problem with my Jupyter install?
Dumb question: What does include() actually do? Does it effectively move the code into the notebook and then compile it? If so, why would we expect a reference to a line in the original file?