Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load packages automatically without `using` in Julia?

Tags:

julia

When looking at files like this: https://github.com/simon-lc/Silico.jl/blob/main/examples/demo/peg_in_hole_planning.jl

The author does not call "using Silico" or "using Mehrotra" anywhere, yet calls it many times throughout the file. As someone coming from Python, I don't understand this. How does Julia know where to look for Silico without a statement like "using Silico"?

like image 782
user3180 Avatar asked Jun 16 '26 15:06

user3180


1 Answers

For this, you can customize the configuration file of Julia. For example, in Windows OS, you can go to the following path:
C://Users//.julia/config/startup.jl
Open the file and write the importing command(s) you want. E.g., using Term or using OhMyREPL and using Statistics: mean, std (then those functions will be available by default). Then every time you run the Julia, those packages will be imported automatically.

*Note that if this file doesn't exist in the path, you can create a file with the same name.

You can also compile the preferred packages into the Julia system image, and the Julia REPL will start a bit quicker since it does not have to parse and compile the package when loaded. The way to do this is by using PackageCompiler.jl. [1]

like image 96
Shayan Avatar answered Jun 22 '26 02:06

Shayan