# Calling a module from a module in a different directory

**URL:** <https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024>\
**Category:** General Usage\
**Created:** [April 11, 2019, 8:19am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024 "2019-04-11T08:19:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [April 11, 2019, 8:19am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/1 "2019-04-11T08:19:17Z")

</div>

Hi,  
just a question about calling a module from another module which is located in a different directory. For instance imagine I have a module mytypes.jl

```julia
module myTypes
export CROCO, krok1
export bite
abstract type CROCO end
struct krok1
   x :: Int64
end
function bite(x)
   return x*x
end
end

```

in folder /home/animals/modules/Reptiles  
Now I have a second folder /home/animals/modules/Beasts  
where I have a second mudule that has to use the myTypes module

```julia
module myFuncs
push!(LOAD_PATH,"/home/animals/modules/Reptiles");
using myTypes
function cayman(c::CROCO)
   return c.x
end
end

```

My problem is that, when trying to load myFuncs, it fails and complains because it can’t understand the CROCO variable, as if the module myTypes.jl has not been loaded -or maybe is a scoping problem (?)  
Bottom line is: how can I make myFuncs module load and understand the data and function in myTypes modules, both being in different directories?  
Best regards and thanks,  
Ferran.

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [April 11, 2019, 9:17am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/2 "2019-04-11T09:17:51Z")

</div>

Is mytypes vs myTypes just a typo here?

---

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [April 11, 2019, 9:58am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/3 "2019-04-11T09:58:07Z")

</div>

Yes… Changed that in the original post.

---

<div class="post-metadata">

**Author:** ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)\
**Post date:** [April 11, 2019, 10:00am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/4 "2019-04-11T10:00:23Z")

</div>

`CROCO` is not exported.

---

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [April 11, 2019, 10:01am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/5 "2019-04-11T10:01:58Z")

</div>

Fixed, but that was not the problem ☹ Of course it was a problem, but not the one I would like to solve…

---

<div class="post-metadata">

**Author:** ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)\
**Post date:** [April 11, 2019, 10:28am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/6 "2019-04-11T10:28:38Z")

</div>

Should work as is.  
~~By the way, the `c.x` in `myFuncs` will fail unless `krok1<:CROCO`~~

---

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [April 11, 2019, 10:39am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/7 "2019-04-11T10:39:21Z")

</div>

Unfortunately, it doesn’t work. I mean to say, it does not work on my system -or I can’t make it work…

---

<div class="post-metadata">

**Author:** ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)\
**Post date:** [April 11, 2019, 10:43am UTC](https://discourse.julialang.org/t/calling-a-module-from-a-module-in-a-different-directory/23024/8 "2019-04-11T10:43:29Z")

</div>

Check that the path is correct and that the file is named `myTypes.jl`. It works in my case.
