Lesson1 - creating .jl file and running it from Julia

Hi there,

I’ve installed Julia - using a Mac.
I’ve created my first julia file and saved it in my Folder on my Desktop as a .jl file using Brackets (as text editor). When I launch Julia and type: include(“Example1.jl”) enter

I get an error!
SystemError: opening file “/Users/kassen/Example1.jl”: No such file or directory
Please help!
Thanks

Your file seems to lie in /Users/kassen/Desktop/<somefolder>/Example.jl whereas Julia by default starts in your home directory, i.e. /Users/kassen. You have a few options to get things working:

  1. Use absolute path: include("/Users/kassen/Desktop/<somefolder>/Example.jl")
  2. cd into the directory of the file: cd("/Users/kassen/Desktop/<somefolder>") followed by include("Example1.jl").
  3. Start Julia in the directory /Users/kassen/Desktop/<somefolder>/ in the first place: use e.g. Terminal or iTerm2 to navigate to the folder and then start julia with the julia command.

Merry Christmas! :slight_smile:

3 Likes

Welcome @Derrick_Kassen !

Try to run the script with:

julia /path/to/script.jl

If you are learning Julia for the first time, consider trying things out in Pluto, it is a good platform for beginners because it handles package installation, shows the results right away, etc.

Merry Xmas! :christmas_tree: :julia:

1 Like

Thank you & Merry Christmas to you 2!