Julia build errors not making sense

Viewed 89

So I'm new to Julia and I'm testing out some of it's GUI capabilities with Cairo and Tk. I'm following one of the tutorials on the Julia website and I've tried out the code they have for it.

using Base.Graphics
using Cairo
using Tk

win = Toplevel("Test", 400, 200)
c = Canvas(win)
pack(c, expand=true, fill="both")

The Stacktrace it generates is as follows:

ERROR: LoadError: UndefVarError: Graphics not defined
Stacktrace:
  [1] include(::Function, ::Module, ::String) at ./Base.jl:380
  [2] include(::Module, ::String) at ./Base.jl:368
  [3] exec_options(::Base.JLOptions) at ./client.jl:296
  [4] _start() at ./client.jl:506
in expression starting at /path/to/my/julia/program.jl:1

I've installed the Graphics package, but that didn't seem to help anything. I tried to install the Base package, but it told me "* Base (not found in project, manifest or registry)."

Maybe it's me, but this trace isn't really helping describe the issue. It says Graphics is not defined, but then acts like Base is the issue. What's going on here? Any help is appreciated.

1 Answers

Your reading of the error was correct when you interpreted you needed to install the package: Julia is not finding a Graphics submodule inside Base (when you do using Base.Graphics, you are instructing Julia to look for the name "Graphics" inside "Base",which is why the error appears there).

What is happening is that you are following an 8 year-old blog post, from way before Julia reached its 1.0 version. Since then, the Graphics module was taken out of Base

For what I could see, if you installed the Graphics package now you should do:

using Graphics
using Cairo
using Tk

If you have not installed the package, then:

]add Graphics #(the package is now a separate package, do this only the first time)
using Graphics

But by the age of the blog post, it could be possible that you run into further issues. Let's see if someone can point you to newer material regarding graphical interfaces.

Related