# Difference between include, use and import

**URL:** <https://discourse.julialang.org/t/difference-between-include-use-and-import/65918>\
**Category:** General Usage\
**Created:** [August 6, 2021, 1:19am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918 "2021-08-06T01:19:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CRquantum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crquantum/32/27824_2.png) [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Post date:** [August 6, 2021, 1:19am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918/1 "2021-08-06T01:19:04Z")

</div>

I read about include, use and import in Julia.  
It seems they can all be used to ‘import’ a module.

But I am still not very clear the difference between include, use and import.  
if I have a module called Mymod, and I want to use it in the main program,  
is  
include(“Mymod.jl”) enough?

Or do I have to do,  
include(“Mymod.jl”)  
use .Mymod

Also, could anyone please explain a little bit more,  
so, when to use ‘use’, and when to use ‘import’?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [August 6, 2021, 1:32am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918/2 "2021-08-06T01:32:19Z")

</div>

> [@CRquantum](#):
>
> include(“Mymod.jl”)  
> use .Mymod

Yes, you need to do that, unless it is a package and is installed as such.

For the differences between using and import, the manual is very didactical: [Modules · The Julia Language](https://docs.julialang.org/en/v1/manual/modules/#Standalone-using-and-import)

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 6, 2021, 5:49am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918/3 "2021-08-06T05:49:55Z")

</div>

> [@CRquantum](#):
>
> I read about include, use and import in Julia.  
> It seems they can all be used to ‘import’ a module.
> 
> But I am still not very clear the difference between include, use and import.

What have you read? What exactly are you unclear about?

`include` is used for including the content of a file into your current program. It has per se nothing to do with modules or namespaces. `using` and `import` on the other hand have nothing to do with files, and deal exclusively with modules/namespaces.

---

<div class="post-metadata">

**Author:** ![CRquantum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crquantum/32/27824_2.png) [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Post date:** [August 11, 2021, 8:37am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918/4 "2021-08-11T08:37:31Z")

</div>

Thank you I got it.

If I have some variable or function in the export list in the module NiceStuff,  
like

```
export Superman

```

then I do

```
using NiceStuff

```

I can use Superman directly.

In contrast,

```julia
    import NiceStuff

```

brings _only_ the module name into scope.  
Therefore Superman alone does not work, I have to specify NiceStuff.Superman all the time.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 11, 2021, 9:05am UTC](https://discourse.julialang.org/t/difference-between-include-use-and-import/65918/5 "2021-08-11T09:05:35Z")

</div>

Yes, that’s the difference between `using` and `import` - the former brings all exported names into scope, while the latter only brings `NiceStuff` (the module identifier) into scope.

[https://docs.julialang.org/en/v1/manual/modules/#Standalone-using-and-import](https://docs.julialang.org/en/v1/manual/modules/#Standalone-using-and-import)
