我无法让 datalad 在 python jupyter 实验室笔记本中工作,但它在常规终端中工作正常。我是否需要专门做一些事情来将 datalad 与 Jupyter 笔记本集成?我是根据 Datalad 手册安装的:http://handbook.datalad.org/en/latest/intro/installation.html#install。以下是一些细节:
机器规格:macOS Mojave 10.14.6,Python 3.8.5,使用 anaconda
使用 !使用 shell 终端安装,但在终端应用程序中工作。 这是我尝试使用 data lad 时的 jupyter 终端示例:!datalad status --annex all;产生此错误: [ERROR ] 版本 >= 7.20190503 的 git-annex 丢失。有关如何安装 DataLad 和 git-annex 的说明,请访问 http://handbook.datalad.org/r.html?install。 [annexrepo.py:_check_git_annex_version:555] (MissingExternalDependency)
我尝试在 jupyter (pip install datalad) 中进行 pip install 并且它给了我这个警告,但其他方面似乎没问题:警告:目录 '/Users/eprzysinda/Library/ Caches/pip' 或其父目录不属于当前用户或不可写。缓存已被禁用。检查该目录的权限和所有者。如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志。
当我尝试导入 datalad.api 时,我收到一个很长的运行时错误,但从这个开始:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-41-e10c67ed4457> in <module>
1 import os
2 import glob
----> 3 import datalad.api as dl
4 #import pandas as pd
5
/opt/anaconda3/lib/python3.8/site-packages/datalad/__init__.py in <module>
46
47 from .config import ConfigManager
---> 48 cfg = ConfigManager()
49
50 from .log import lgr
/opt/anaconda3/lib/python3.8/site-packages/datalad/config.py in __init__(self, dataset, overrides, source)
344 self._runner = GitWitlessRunner(**run_kwargs)
345
--> 346 self.reload(force=True)
347
348 if not ConfigManager._checked_git_identity:
/opt/anaconda3/lib/python3.8/site-packages/datalad/config.py in reload(self, force)
397 while to_run:
398 store_id, runargs = to_run.popitem()
--> 399 self._stores[store_id] = self._reload(runargs)
400
401 # always update the merged representation, even if we did not reload
/opt/anaconda3/lib/python3.8/site-packages/datalad/config.py in _reload(self, run_args)
425 def _reload(self, run_args):
426 # query git-config
--> 427 stdout, stderr = self._run(
428 run_args,
429 protocol=StdOutErrCapture,
/opt/anaconda3/lib/python3.8/site-packages/datalad/config.py in _run(self, args, where, reload, **kwargs)
787 if '-l' in args:
788 # we are just reading, no need to reload, no need to lock
--> 789 out = self._runner.run(self._config_cmd + args, **kwargs)
790 return out['stdout'], out['stderr']
791
/opt/anaconda3/lib/python3.8/site-packages/datalad/cmd.py in run(self, cmd, protocol, stdin, cwd, env, **kwargs)
377 lgr.debug('Async run:\n cwd=%s\n cmd=%s', cwd, cmd)
378 # include the subprocess manager in the asyncio event loop
--> 379 results = event_loop.run_until_complete(
380 run_async_cmd(
381 event_loop,
/opt/anaconda3/lib/python3.8/asyncio/base_events.py in run_until_complete(self, future)
590 """
591 self._check_closed()
--> 592 self._check_running()
593
594 new_task = not futures.isfuture(future)
/opt/anaconda3/lib/python3.8/asyncio/base_events.py in _check_running(self)
550 def _check_running(self):
551 if self.is_running():
--> 552 raise RuntimeError('This event loop is already running')
553 if events._get_running_loop() is not None:
554 raise RuntimeError(
RuntimeError: This event loop is already running
Let me know if anyone has any ideas on this. I'm new to python and jupyter lab, so it's very possible I'm missing something obvious.
Thank you!
~Emily
答案 0 :(得分:0)
我已在 Jupyter Discourse Forum here 上发布了针对此问题的解决方案,其中涉及导入 nest_asyncio
并在导入 datalad 之前根据建议 here 应用它。
以后如果您要向多个社区寻求帮助,请链接到您的帖子。让多个小组一起解决您的问题只会分散资源,并可能使所有相关人员的努力加倍。它还可能使那些遇到相同问题的人无法找到解决方案,因为他们没有意识到其他地方可能有答案。
答案 1 :(得分:0)
Fwiw:Datalad 的当前主分支(最终将作为 0.15.0 发布)已经取代了 runner 的 asyncio 植入,并且必须在 jupyterlab 等中工作,而无需任何变通方法。