Well, first of all do NOT checkout PowerModuls.jl or any other package you want to use from git. (Unless you want to modify it). Do NOT use the Project.toml file from any package, create your own instead.
Example:
mkdir test
cd test
julia --project="."
using Pkg
pkg"add PowerModels"
pkg"add Ipopt"
Now you have a project folder with the package PowerModels and Ipopt installed (and with no other package, so no conflicts).
Now quit Julia (ctrl+d) and create a folder with your examples:
mkdir examples
cd examples
gedit first_example.jl
(Or use your favorite editor instead of gedit).
Paste the following lines into the editor:
using PowerModels
using Ipopt
solve_ac_opf("matpower/case3.m", Ipopt.Optimizer)
Save the file.
Go back to the project directory and have a look what is there:
cd ..
tree
The output should look like:
ufechner@tuxedi:~/repos/tmp$ tree
.
├── examples
│ └── first_example.jl
├── Manifest.toml
└── Project.toml
Now start Julia and run the example:
julia --project
include("examples/first_example.jl")
I suggest that beginners should learn to use the REPL first, when they know how to use it they can switch to vscode… vscode is more difficult to explain and has a lot of settings that you can set wrongly.
Another problem is that this example from the quickstart guide of the package PowerModels does not work. I created an issue in the package: Example does not work · Issue #826 · lanl-ansi/PowerModels.jl · GitHub
To fix the example, create a folder matpower, put the following file into it: https://raw.githubusercontent.com/power-grid-lib/pglib-opf/master/pglib_opf_case5_pjm.m and rename it to case3.m
The directory structure now looks like this:
ufechner@tuxedi:~/repos/tmp$ tree
.
├── examples
│ └── first_example.jl
├── Manifest.toml
├── matpower
│ └── case3.m
└── Project.toml
And Project.toml looks like this:
ufechner@tuxedi:~/repos/tmp$ cat Project.toml
[deps]
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
Now I could run the example and get the output:
EXIT: Optimal Solution Found.
Dict{String, Any} with 8 entries:
"solve_time" => 3.35954
"optimizer" => "Ipopt"
"termination_status" => LOCALLY_SOLVED
"dual_status" => FEASIBLE_POINT
"primal_status" => FEASIBLE_POINT
"objective" => 17551.9
"solution" => Dict{String, Any}("baseMVA"=>100.0, "branch"=>Dict{St…
"objective_lb" => -Inf
Another source of confusion might be that you were linking to an old version of PowerModels from a mirror. Do NOT use outdated versions, always use the original.