I'm trying to include a Julia function (PowerModelsDistribution.solve_mc_opf) in some Python code. The package works in Julia but I'm getting stuck on including it with PyJulia. I've tried a few things:
1.
from julia import Pkg
Pkg.activate("C:/Users/Aisling/.julia/environments/pmd") # pmd is my Julia env but I've also tried this in my base
from julia.PowerModelsDistribution import solve_mc_opf
Results in
ImportError Traceback (most recent call last)
<ipython-input-33-6e83bbbb609c> in <module>
----> 1 from julia.PowerModelsDistribution import solve_mc_opf
C:\ProgramData\Anaconda3\lib\site-packages\julia\core.py in load_module(self, fullname)
258 JuliaModule(self, fullname))
259
--> 260 raise ImportError("{} not found".format(juliapath))
261
262
ImportError: PowerModelsDistribution.solve_mc_opf not found
- And then I tried:
import julia
jl = julia.Julia()
res = jl.run(PowerModelsDistribution.solve_mc_opf("documents/powermodelsdistribution/test/data/opendss/case3_unbalanced.dss", ACPUPowerModel, Ipopt.Optimizer))
Results in:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-29-2af5367df821> in <module>
----> 1 res = jl.run(PowerModelsDistribution.solve_mc_opf("documents/powermodelsdistribution/test/data/opendss/case3_unbalanced.dss", ACPUPowerModel, Ipopt.Optimizer))
C:\ProgramData\Anaconda3\lib\site-packages\julia\core.py in __getattr__(self, name)
174 def __getattr__(self, name):
175 try:
--> 176 return self.__try_getattr(name)
177 except AttributeError:
178 if name.endswith("_b"):
C:\ProgramData\Anaconda3\lib\site-packages\julia\core.py in __try_getattr(self, name)
197 return self._julia.eval(jl_fullname)
198
--> 199 raise AttributeError(name)
200
201
AttributeError: solve_mc_opf
I'm stumped.
from julia import PowerModelsDistribution
(returns no errors). The devs on PMD said it might be because they loop the export call (`for sym in names... @eval export $sym). – Yetty