0

我无法让 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] git-annex of version >= 7.20190503 is missing。有关如何安装 DataLad 和 git-annex 的说明,请访问http://handbook.datalad.org/r.html?install 。[annexrepo.py:_check_git_annex_version:555](缺少外部依赖)

我试图在 jupyter ( pip install datalad ) 中进行 pip 安装,它给了我这个警告,但其他方面似乎没问题:警告:目录 '/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
4

2 回答 2

0

我已经在这里的 Jupyter Discourse 论坛上发布了一个解决这个问题的解决方案,其中涉及nest_asyncio在导入 datalad 之前导入和应用它,基于这里的建议。


将来,如果您要向多个社区寻求帮助,请链接到您的帖子。让多个小组一起解决您的问题只会分配资源,并可能使所有相关人员的努力加倍。它还可能会破坏为那些有同样问题的人寻找解决方案的途径,因为他们没有意识到其他地方可能有答案。

于 2021-05-17T16:23:59.580 回答
0

Fwiw:Datalad 的当前主分支(最终将作为 0.15.0 发布)已取代运行器的 asyncio 植入,并且必须在 jupyterlab 等中工作,无需任何变通方法。

于 2021-06-15T01:49:56.157 回答