pyjulia - gher-uliege/Documentation GitHub Wiki
pyjulia allows to call Julia code from Python.
First check that the correction version of Julia is in your PATH:
which juliaInstall PyCall
julia -e 'Pkg.add("PyCall")'Install pyjulia
git clone https://github.com/JuliaPy/pyjulia
cd pyjulia/
python2 setup.py clean
python2 setup.py install --prefix $HOME/.local/Simple check:
~/.julia/v0.6/Conda/deps/usr/bin/python2.7 -c "import julia; j = julia.Julia(); j.versioninfo(); print j.sind(90)"This command should return the following:
WARNING: redefining constant JULIA_HOME
Julia Version: ...
...
1.0
Just issuing
/usr/bin/python -c "import julia; j = julia.Julia(); j.versioninfo(); print j.sind(90)"fails with
InitError(:PyCall, PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)) <type 'exceptions.SystemError'>
SystemError('dynamic module not initialized properly',)
...
The work-around is to use the python interpreter from miniconda.
python -m unittest discoverIf you see the following error:
OSError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/abarth/opt/julia-3c9d75391c/bin/../lib/libjulia.so.0.5)
Define the variable LD_PRELOAD before starting python or (ipython)
export LD_PRELOAD="$HOME/opt/julia-xyz/lib/julia/libstdc++.so.6"You should adapt the path in the previous command to match the installation location of Julia.
On some systems, python crashes on j = julia.Julia() (https://github.com/JuliaPy/pyjulia/issues/66). Rebuilding PyCall after installing pyjulia seems to solve this issue. In Julia, run the following command:
Pkg.build("PyCall")Maybe the version of julia has changed since pyjulia was installed the last time. Recompile pyjulia with the correction version of julia.
File "/home/abarth/.julia/v0.6/Conda/deps/usr/lib/python2.7/re.py", line 108, in <module>
import _locale
SystemError: dynamic module not initialized properly