pyjulia
pyjulia copied to clipboard
**from julia import Base** crash
Hi, I am trying to use the package as you recommend in the README without success. I am using ipython. First I installed the julia package in python:
pip3 install--user julia
test:
python-jl
ERROR: PyError (PyImport_ImportModule
The Python package julia.pseudo_python_cli could not be found by pyimport. Usually this means
that you did not install julia.pseudo_python_cli in the Python version being used by PyCall.
PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package. To install the julia.pseudo_python_cli module, you can
use `pyimport_conda("julia.pseudo_python_cli", PKG)`, where PKG is the Anaconda
package the contains the module julia.pseudo_python_cli, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).
Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python. As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.
) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'julia'")
Stacktrace:
[1] pyimport(::String) at /Users/ruben/.julia/packages/PyCall/ttONZ/src/PyCall.jl:544
[2] top-level scope at none:4
Testing with ipython:
$ ipython
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import julia
In [2]: julia.install()
[ Info: Julia version info
Julia Version 1.3.1
Commit 2d5741174c (2019-12-30 21:36 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.6.0)
uname: Darwin 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64 i386
CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz:
speed user nice sys idle irq
#1 2600 MHz 429786 s 0 s 253812 s 2372269 s 0 s
#2 2600 MHz 48902 s 0 s 23796 s 2980660 s 0 s
#3 2600 MHz 391503 s 0 s 168982 s 2492895 s 0 s
#4 2600 MHz 48427 s 0 s 21298 s 2983603 s 0 s
#5 2600 MHz 325742 s 0 s 133917 s 2593718 s 0 s
#6 2600 MHz 47914 s 0 s 19319 s 2986093 s 0 s
#7 2600 MHz 273164 s 0 s 102260 s 2677951 s 0 s
#8 2600 MHz 48161 s 0 s 18054 s 2987108 s 0 s
Memory: 16.0 GB (33.0390625 MB free)
Uptime: 1.948836e6 sec
Load Avg: 2.666015625 2.51611328125 2.58203125
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
CPLUS_INCLUDE_PATH = /anaconda2/pkgs/eigen-3.3.7-h04f5b5a_1000/include/eigen3:/opt/intel/debugger_2019/gdb/intel64/include/:/Users/ruben/software/include::/Users/ruben/anaconda2/include/python2.7/
LDFLAGS = -L/usr/local/opt/llvm/lib
MANPATH = /sw/share/man:/opt/intel/man/common:/opt/intel//documentation_2019/en/debugger/gdb-ia/man/:/opt/intel/man:/usr/local/share/man:/usr/share/man:/Applications/Forest SDK/man:/Library/TeX/texbin/man:/opt/X11/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man:/sw/lib/perl5/5.18.4/man
TERM = xterm-256color
CPPFLAGS = -I/usr/local/opt/llvm/include
LIBRARY_PATH = /opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/ipp/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/daal/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/daal/../tbb/lib
CPATH = /opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/ipp/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/pstl/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/include:/opt/intel/compilers_and_libraries_2019.4.233/mac/daal/include
NLSPATH = /opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib/locale/%l_%t/%N:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/locale/en_US/%N:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib/locale/%l_%t/%N:/opt/intel//debugger_2019/gdb/intel64/share/locale/%l_%t/%N
PATH = /Users/ruben/anaconda3/bin:/Users/ruben/anaconda3/condabin:/sw/bin:/sw/sbin:/usr/local/opt/llvm/bin:/usr/local/opt/libxml2/bin:/Users/ruben/perl5/bin:/Users/ruben/anaconda2/bin:/usr/local/gcc-7.1/bin:/opt/intel/compilers_and_libraries_2019.4.233/mac/bin/intel64:/opt/intel/debugger_2019/gdb/intel64/bin:/usr/local/psi4/bin:/opt/intel/bin:/Users/ruben/anaconda2/include/boost:/usr/local/Cellar/gcc/7.2.0/bin:/Applications/TeXShop.app/Contents/Resources:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/intel/lib:/Applications/Forest SDK/bin:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools
C_INCLUDE_PATH = /usr/local/Cellar/eigen/3.3.7/include/eigen3/Eigen:/Users/ruben/software/include:/Users/ruben/software/include:/opt/intel/compilers_and_libraries_2017.2.163/mac/mkl/include/:/usr/X11R6/include/:
LUA_PATH = /Users/ruben/.local/share/luarocks/share/lua/5.3/?.lua;
LUA_CPATH = /Users/ruben/.local/share/luarocks/lib/lua/5.3/?.so;
XPC_FLAGS = 0x0
INTEL_PYTHONHOME = /opt/intel//debugger_2019/python/intel64/
HOME = /Users/ruben
DYLD_LIBRARY_PATH = /usr/local/gcc-7.1/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib/intel64:/opt/intel/compilers_and_libraries_2019.4.233/mac/ipp/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/compiler/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/tbb/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/daal/lib:/opt/intel/compilers_and_libraries_2019.4.233/mac/daal/../tbb/lib:/Users/ruben/Work/CodeProjects/OpenCL/cl_utils/clbox_experm/bin:/Users/ruben/software/lib:/usr/local/Cellar/gcc/7.2.0/lib:
PYTHONPATH = /Users/ruben/Repositories/fragbuilder:/Useers/ruben/Work/Enhanced_sampling/pele:/Useers/ruben/Work/Enhanced_sampling/sen:/Useers/ruben/Work/Enhanced_sampling/nested_sampling:/Users/ruben/Repositories/pyscf/:/Users/ruben/anaconda2:
CLASSPATH = /opt/intel/compilers_and_libraries_2019.4.233/mac/daal/lib/daal.jar
PKG_CONFIG_PATH = /opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/bin/pkgconfig:/opt/intel/compilers_and_libraries_2019.4.233/mac/mkl/bin/pkgconfig
INFOPATH = /sw/share/info:/sw/info:/opt/intel//documentation_2019/en/debugger/gdb-ia/info/
[ Info: Julia executable: /Applications/Julia-1.3.app/Contents/Resources/julia/bin/julia
[ Info: Trying to import PyCall...
┌ Warning: PyCall is already installed. However, you may have trouble using
│ this Python executable because it is statically linked to libpython.
│
│ For more information, see:
│ https://pyjulia.readthedocs.io/en/latest/troubleshooting.html
│
│ Python executable:
│ /Users/ruben/anaconda3/bin/python
│ Julia executable:
│ /Applications/Julia-1.3.app/Contents/Resources/julia/bin/julia
└ @ Main ~/anaconda3/lib/python3.7/site-packages/julia-0.5.2.dev0-py3.7.egg/julia/install.jl:74
In [3]: from julia import Base
---------------------------------------------------------------------------
UnsupportedPythonError Traceback (most recent call last)
<ipython-input-3-5063b14d431c> in <module>
----> 1 from julia import Base
~/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_)
~/anaconda3/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)
~/anaconda3/lib/python3.7/importlib/_bootstrap.py in _load_unlocked(spec)
~/anaconda3/lib/python3.7/importlib/_bootstrap.py in _load_backward_compatible(spec)
~/anaconda3/lib/python3.7/site-packages/julia-0.5.2.dev0-py3.7.egg/julia/core.py in load_module(self, fullname)
245 return sys.modules.setdefault(fullname,
246 JuliaMainModule(self, fullname))
--> 247 elif self.julia.isafunction(juliapath):
248 return self.julia.eval(juliapath)
249
~/anaconda3/lib/python3.7/site-packages/julia-0.5.2.dev0-py3.7.egg/julia/core.py in julia(self)
236 @property
237 def julia(self):
--> 238 self.__class__.julia = julia = Julia()
239 return julia
240
~/anaconda3/lib/python3.7/site-packages/julia-0.5.2.dev0-py3.7.egg/julia/core.py in __init__(self, init_julia, jl_init_path, runtime, jl_runtime_path, debug, **julia_options)
480 logger.debug("compiled_modules = %r", options.compiled_modules)
481 if not (options.compiled_modules == "no" or is_compatible_python):
--> 482 raise UnsupportedPythonError(jlinfo)
483
484 self.api.init_julia(options)
UnsupportedPythonError: It seems your Julia and PyJulia setup are not supported.
Julia executable:
julia
Python interpreter and libpython used by PyCall.jl:
/Users/ruben/.julia/conda/3/bin/python
/Users/ruben/.julia/conda/3/lib/libpython3.7m.dylib
Python interpreter used to import PyJulia and its libpython.
/Users/ruben/anaconda3/bin/python
/Users/ruben/anaconda3/lib/libpython3.7m.dylib
Your Python interpreter "/Users/ruben/anaconda3/bin/python"
is statically linked to libpython. Currently, PyJulia does not fully
support such Python interpreter.
The easiest workaround is to pass `compiled_modules=False` to `Julia`
constructor. To do so, first *reboot* your Python REPL (if this happened
inside an interactive session) and then evaluate:
>>> from julia.api import Julia
>>> jl = Julia(compiled_modules=False)
Another workaround is to run your Python script with `python-jl`
command bundled in PyJulia. You can simply do:
$ python-jl PATH/TO/YOUR/SCRIPT.py
See `python-jl --help` for more information.
For more information, see:
https://pyjulia.readthedocs.io/en/latest/troubleshooting.html
The important part is this:
┌ Warning: PyCall is already installed. However, you may have trouble using
│ this Python executable because it is statically linked to libpython.
│
│ For more information, see:
│ https://pyjulia.readthedocs.io/en/latest/troubleshooting.html
│
│ Python executable:
│ /Users/ruben/anaconda3/bin/python
│ Julia executable:
│ /Applications/Julia-1.3.app/Contents/Resources/julia/bin/julia
As explained in https://pyjulia.readthedocs.io/en/latest/troubleshooting.html, you need to use a different Python executable that is not statically linked to libpython or use one of the workarounds.
The python-jl
part is probably a bug like #336.