JuliaPy / pyjulia

python interface to julia
MIT License
884 stars 103 forks source link

Broken pipe when running script in Anaconda #288

Open redransil opened 5 years ago

redransil commented 5 years ago

This line:

jl.eval('run_ac_opf("pglib_opf_case5_pjm.m", IpoptSolver())')

gives a broken pipe error:

JuliaError: Exception 'IOError: write: broken pipe (EPIPE)' occurred while calling julia code: run_ac_opf("pglib_opf_case5_pjm.m", IpoptSolver())

But only if I've already run the script. After restarting the terminal everything runs ok the first time. Looking at other issues I think this has something to do with precompilation? Is there some way I can kill Julia every time I run the script without having to manually restart the terminal?

I'm using Spyder/Anaconda/Ubuntu with Julia(compiled_modules=False)

tkf commented 5 years ago

It looks like PyJulia is just propagating an error in Julia. Does it occure when you run code in pure-Julia without using PyJulia?

this has something to do with precompilation

No, I don't think so. It looks like a normal Julia error.

redransil commented 5 years ago

No, it doesn't occur when I'm running in pure-Julia.

It does happen every time I re-run a script using PyJulia, unless I use a new terminal. I can also call that function multiple times in the same script, or turn it into a class and call the function multiple times from another script using that class. But once it's done running I have to close the terminal.

tkf commented 5 years ago

Hmm... That's very odd. I can't come up with any hypothesis ATM. Is it specific to the terminal in Spyder?

wenglerjoe commented 4 years ago

Hi,

I wanted to ask whether there was a solution to that Problem as I experience the same problem. I can run my script the first time, where Julia is invoked several times without any issue, but when I try to run the same script again, I get an EPIPE error and the script stops working. Also my processor keeps working at high rates, what in my opinion is proof that some Julia instance is still running in the background. I am using Julia 1.3, Python 3.6.7 and Spyder 4.1.0

manuelbb-upb commented 4 years ago

This problem only happens to me if I start a Spyder kernel in the terminal and connect to it in the editor. The default kernel works.

That is, if I run

python3 -m spyder_kernels.console

and connect to this kernel in Spyder (v.4.1.4) then every Julia output results in a EPIPE error. The following example would not work:

from julia.api import Julia
Julia(compiled_modules = False)
from julia import Main
Main.eval('println("Hello World")')

Using ipython kernel instead solves my problem. This is curious because according to the documentation such a kernel should not work.

For the time being I will thus continue using ipython kernel in my container.