让datalad在juypter实验室笔记本中工作时出现问题?

2024-04-25 08:33:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法让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终端安装,但在终端应用程序中不起作用。 当我尝试使用数据lad:时,这里有一个jupyter终端示例!datalad状态——附件所有;产生此错误:[error]git版本的附件>;=7.20190503缺失。有关如何安装DataLad和git附件的说明,请访问http://handbook.datalad.org/r.html?install。[annexrepo.py:_check_git_annexment_version:555](缺失外部相关性)

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

Tags: runinpyimportselfconfigiflib
2条回答

Fwiw:Datalad的当前主分支(最终将发布为0.15.0)已经取代了runner的asyncio植入,并且必须在jupyterlab等内部工作,无需任何必要的解决方法

我在Jupyter话语论坛here上发布了一个解决这个问题的方法,根据建议here导入nest_asyncio并在导入datalad之前应用它


将来如果你要向多个社区寻求帮助,请链接到你的帖子。让多个小组来解决您的问题只会分散资源,并可能使所有相关人员的工作加倍。这也有可能使那些有同样问题的人无法找到解决方案,因为他们没有意识到其他地方可能有答案

相关问题 更多 >