Hello everyone! I’m new to programming, so I might need a lot of help! In the lecture (see topic), the include function doesn’t work. It always gives the error “could not open file”, although I have followed every step. Please help!
Can you give us some more detail? What lecture (link?) are you referring to?
file.jl is some file that you like to include, checks for files next to the file that you‘re in. Is the file near your current directory? Use
pwd() to see your current directory
@rdeits Thank you for responding! I’m referring to Lecture 1 in the Julia academy course (Your First Julia Code! Julia Programming For Nervous Beginners (Week 1 Lesson 1) - YouTube), in the third segment of the video, which explains running a code from a file. I saved the file as instructed, but still gives an error message.
@rikh Yes that one! Thanks. Yes, I’ve seen my current directory (C: Users/amro0/). I have the .jl file saved in the path (C: Users/amro0/JuliaCourse/Codes). Is that where I’m wrong?
Are you in the REPL or in a file? In the REPL you can type
where is the tab key on the keyboard which will show which files are in your current directory.
For the file. You could add a
@show readdir() to try to figure out where you are and adjust the path accordingly
Probably, you need something like
Looks like you’ve got a solution. Just a remark in passing, sometimes
expanduser is useful, to help Julia understand that
~ refers to your home directory. And sometimes it’s useful to push an entire directory to the load path. Something like this:
dir = expanduser("~/JuliaCourse/Codes/")