Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia packages not found in vs code

I'm very new to vscode and have been using previously jupyter notebooks. The problem is that when I try to run julia in vs code, it doesn't find any of the packages that have been installed with jupyter. Do I have to reinstall everything or is there some way to fix this?

The julia code works, but not the packages.

like image 200
user21109520 Avatar asked Oct 17 '25 00:10

user21109520


1 Answers

1. Create a project in Julia REPL and activate it

in vs-code: install Julia extension, then ctr+shift+P, Julia: Start Repl

julia> cd("path/to/my/project/folder")
julia> pdw()
julia> ]
pkg> generate myProjectName
pkg> activate .
(myProjectName) pkg>
# hit backspace to go back to julia REPL promt

2. Install a package in the active project

You only need to do this once per package:

julia> ]
(myProjectName) pkg> add aPackageName

3. Check files

  • path/to/my/project/folder/Manifest.toml
  • path/to/my/project/folder/Project.toml

These files holds all package related infos for your project.

4. Organize Sourcecode

Suggestions:

  • Put your *.jl source-files in a sub-folder, eg ./src.
  • Have one module per file:
module MyModule1
    export function1, function2

    include("./MyModule2.jl")

    const A_CONSTANT_VALUE = "fooBar"

    function function1()
        MyModule2.function3()
        ...
    end

    function function2()
    ...
    end
...
end
like image 134
Benvorth Avatar answered Oct 19 '25 18:10

Benvorth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!