#python #julia
Вопрос:
Я следую инструкциям по встраиванию Джулии в записные книжки Python здесь
Я установил Julia, установил PyJulia и установил все пакеты, которые PyJulia требует от Джулии. В блокноте я набрал %load_ext julia.magic
и вернул следующую ошибку. Аналогичная ошибка с. jl = Julia(compiled_modules=False)
Я совсем не уверен, в чем проблема, может кто-нибудь, пожалуйста, объяснить?
ПРИМЕЧАНИЕ: У меня проблема только в блокнотах Jupyter. Я могу работать jl = Julia(compiled_modules=False)
в терминале IPython, но я не могу выполнить эту команду в ноутбуке.
Initializing Julia interpreter. This may take some time...
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-1-a49715008785> in <module>
----> 1 get_ipython().run_line_magic('load_ext', 'julia.magic')
~/conda/envs/julia-py38/lib/python3.8/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2342 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2343 with self.builtin_trap:
-> 2344 result = fn(*args, **kwargs)
2345 return result
2346
~/conda/envs/julia-py38/lib/python3.8/site-packages/decorator.py in fun(*args, **kw)
230 if not kwsyntax:
231 args, kw = fix(args, kw, sig)
--> 232 return caller(func, *(extras args), **kw)
233 fun.__name__ = func.__name__
234 fun.__signature__ = sig
~/conda/envs/julia-py38/lib/python3.8/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/conda/envs/julia-py38/lib/python3.8/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str)
31 if not module_str:
32 raise UsageError('Missing module name.')
---> 33 res = self.shell.extension_manager.load_extension(module_str)
34
35 if res == 'already loaded':
~/conda/envs/julia-py38/lib/python3.8/site-packages/IPython/core/extensions.py in load_extension(self, module_str)
85 dir=compress_user(self.ipython_extension_dir)))
86 mod = sys.modules[module_str]
---> 87 if self._call_load_ipython_extension(mod):
88 self.loaded.add(module_str)
89 else:
~/conda/envs/julia-py38/lib/python3.8/site-packages/IPython/core/extensions.py in _call_load_ipython_extension(self, mod)
132 def _call_load_ipython_extension(self, mod):
133 if hasattr(mod, 'load_ipython_extension'):
--> 134 mod.load_ipython_extension(self.shell)
135 return True
136
~/.local/lib/python3.8/site-packages/julia/magic.py in load_ipython_extension(ip)
156 # This is equivalent to `ip.register_magics(JuliaMagics)` (but it
157 # let us access the instance of `JuliaMagics`):
--> 158 magics = JuliaMagics(shell=ip)
159 ip.register_magics(magics)
160
~/.local/lib/python3.8/site-packages/julia/magic.py in __init__(self, shell)
98 # Flush, otherwise the Julia startup will keep stdout buffered
99 sys.stdout.flush()
--> 100 self._julia = Julia(init_julia=True)
101 print()
102
~/.local/lib/python3.8/site-packages/julia/core.py in __init__(self, init_julia, jl_init_path, runtime, jl_runtime_path, debug, **julia_options)
466 self.api = get_libjulia()
467 elif init_julia:
--> 468 jlinfo = JuliaInfo.load(runtime)
469 if jlinfo.version_info < (0, 7):
470 raise RuntimeError("PyJulia does not support Julia < 0.7 anymore")
~/.local/lib/python3.8/site-packages/julia/juliainfo.py in load(cls, julia, **popen_kwargs)
66 os.path.dirname(os.path.realpath(__file__)), "juliainfo.jl"
67 )
---> 68 proc = subprocess.Popen(
69 [julia, "--startup-file=no", juliainfo_script],
70 stdout=subprocess.PIPE,
~/conda/envs/julia-py38/lib/python3.8/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
856 encoding=encoding, errors=errors)
857
--> 858 self._execute_child(args, executable, preexec_fn, close_fds,
859 pass_fds, cwd, env,
860 startupinfo, creationflags, shell,
~/conda/envs/julia-py38/lib/python3.8/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1704 if errno_num != 0:
1705 err_msg = os.strerror(errno_num)
-> 1706 raise child_exception_type(errno_num, err_msg, err_filename)
1707 raise child_exception_type(err_msg)
1708
FileNotFoundError: [Errno 2] No such file or directory: 'julia'
Ошибка при запуске jl = Julia(compiled_modules=False)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-10-79df07b086bd> in <module>
1 from julia import Julia
----> 2 jl = Julia(compiled_modules=False)
~/.local/lib/python3.8/site-packages/julia/core.py in __init__(self, *args, **kwargs)
678
679 def __init__(self, *args, **kwargs):
--> 680 self.__julia = Julia(*args, **kwargs)
681
682 __init__.__doc__ = Julia.__init__.__doc__
~/.local/lib/python3.8/site-packages/julia/core.py in __init__(self, init_julia, jl_init_path, runtime, jl_runtime_path, debug, **julia_options)
466 self.api = get_libjulia()
467 elif init_julia:
--> 468 jlinfo = JuliaInfo.load(runtime)
469 if jlinfo.version_info < (0, 7):
470 raise RuntimeError("PyJulia does not support Julia < 0.7 anymore")
~/.local/lib/python3.8/site-packages/julia/juliainfo.py in load(cls, julia, **popen_kwargs)
66 os.path.dirname(os.path.realpath(__file__)), "juliainfo.jl"
67 )
---> 68 proc = subprocess.Popen(
69 [julia, "--startup-file=no", juliainfo_script],
70 stdout=subprocess.PIPE,
~/conda/envs/julia-py38/lib/python3.8/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
856 encoding=encoding, errors=errors)
857
--> 858 self._execute_child(args, executable, preexec_fn, close_fds,
859 pass_fds, cwd, env,
860 startupinfo, creationflags, shell,
~/conda/envs/julia-py38/lib/python3.8/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1704 if errno_num != 0:
1705 err_msg = os.strerror(errno_num)
-> 1706 raise child_exception_type(errno_num, err_msg, err_filename)
1707 raise child_exception_type(err_msg)
1708
FileNotFoundError: [Errno 2] No such file or directory: 'julia'
Комментарии:
1. Вы добавили двоичный файл julia в переменную среды PATH? Посмотри на это .
2. Я уже добавил его в свой файл .bashrc
export PATH="$PATH:/home/myself/julia-1.6.2/bin"
и перезапустил сеанс. Я также обновил вопрос, чтобы изолировать проблему только с записными книжками.3. Это действительно сработало? Вы можете проверить это в своем блокноте с
import os; os.getenv('PATH')
помощью .4. О, вы правы, это не на ПУТИ! Как мне это исправить?