# Loading functions defined in .jl file to jupyter notebook

**URL:** <https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444>\
**Category:** General Usage\
**Created:** [December 27, 2020, 8:48am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444 "2020-12-27T08:48:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgautam03](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tgautam03/32/20545_2.png) [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Post date:** [December 27, 2020, 8:48am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/1 "2020-12-27T08:48:40Z")

</div>

Hi, I’ve defined a .jl file with several functions and I want to use them to do some calculations in jupyter notebook. I tried using `include("../src/LinAL.jl")` but it gives an error

```julia
could not open file /home/tushar/dev/julia/NumericalMethods.jl/src/LinAL.jl

Stacktrace:
 [1] include(::String) at ./client.jl:457
 [2] top-level scope at In[15]:1
 [3] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

```

I’m not sure how I can load functions from .jl file.

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [December 27, 2020, 11:29am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/2 "2020-12-27T11:29:11Z")

</div>

I’m not totally sure what’s wrong but include works using paths (like you did).

What I could imagine is, that you started the Jupyter notebook in a certain folder and you can’t access a folder which is one level with respect to where the notebook was started.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 27, 2020, 1:32pm UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/3 "2020-12-27T13:32:54Z")

</div>

> [@tgautam03](#):
>
> `could not open file /home/tushar/dev/julia/NumericalMethods.jl/src/LinAL.jl`

Does the file exist? Does it have read permissions? e.g. try opening Julia in a terminal and running `include("/home/tushar/dev/julia/NumericalMethods.jl/src/LinAL.jl")`

`include` should generally work fine in notebooks.

---

<div class="post-metadata">

**Author:** ![tgautam03](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tgautam03/32/20545_2.png) [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Post date:** [January 3, 2021, 4:35am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/4 "2021-01-03T04:35:14Z")

</div>

I’m get the same error in julia terminal as well. The file exists but I don’t know about read permissions. How do I check for read permissions?

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [January 4, 2021, 12:24pm UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/5 "2021-01-04T12:24:49Z")

</div>

Are you using Unix based or Windows?

For example, in Linux the file could be:

```julia
$ ls -l /tmp/lol.jl
-rwx------ 1 root root 374 Jan 4 13:18 /tmp/lol.jl

```

which means that root is owner and only root can read, write, execute it.

In Julia then it says:

```julia
julia> include("/tmp/lol.jl")
ERROR: could not open file /tmp/lol.jl
Stacktrace:
 [1] include(::String) at ./client.jl:457
 [2] top-level scope at REPL[7]:1
 [3] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.3/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

```

Did you use autocompletion (via `<TAB>` in the Julia REPL) to navigate to the file? If a file/path isn’t autocompleted, that would be a hint that probably something with reading permissions is wrong.

---

<div class="post-metadata">

**Author:** ![tgautam03](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tgautam03/32/20545_2.png) [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Post date:** [January 8, 2021, 8:13am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/6 "2021-01-08T08:13:53Z")

</div>

Yes, I can’t access the folder using autocomplete. How do I fix this?

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [January 8, 2021, 8:14am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/7 "2021-01-08T08:14:19Z")

</div>

And it also autocompletes the file you want access?

Can you also try to start the Julia REPL within that folder? Can you include it directly here? (filename without path)

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [January 8, 2021, 8:17am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/8 "2021-01-08T08:17:20Z")

</div>

aj _can’t_ 😃

Do you have root on the system? Otherwise it could be the case that you aren’t allowed to modify permissions…

How did you create the folder and the file? Can you print out permissions via `ls -l` in a terminal located where the folder is.

---

<div class="post-metadata">

**Author:** ![tgautam03](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tgautam03/32/20545_2.png) [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Post date:** [January 8, 2021, 8:25am UTC](https://discourse.julialang.org/t/loading-functions-defined-in-jl-file-to-jupyter-notebook/52444/9 "2021-01-08T08:25:15Z")

</div>

I changed the permissions from the properties and can now tab autocomplete.
