Importing datalad in python

Hi,

I am trying to import datalad in python but I get the below error.
my Python version is 3.7.9 and datalad version is 0.14.0
any help would be greatly appreciated

Erorr
"
RuntimeError Traceback (most recent call last)
in
9 import matplotlib.gridspec as gridspec
10 from nilearn.plotting import plot_stat_map
—> 11 import datalad.api as dl
12 import warnings
13

~.conda\envs\naturalistic\lib\site-packages\datalad_init_.py in
45
46 from .config import ConfigManager
—> 47 cfg = ConfigManager()
48
49 from .log import lgr

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in init(self, dataset, overrides, source)
272 self._runner = GitWitlessRunner(**run_kwargs)
273
→ 274 self.reload(force=True)
275
276 if not ConfigManager._checked_git_identity:

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in reload(self, force)
325 while to_run:
326 store_id, runargs = to_run.popitem()
→ 327 self._stores[store_id] = self._reload(runargs)
328
329 # always update the merged representation, even if we did not reload

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in _reload(self, run_args)
357 protocol=StdOutErrCapture,
358 # always expect git-config to output utf-8
→ 359 encoding=‘utf-8’,
360 )
361 store = {}

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in _run(self, args, where, reload, **kwargs)
715 if ‘-l’ in args:
716 # we are just reading, no need to reload, no need to lock
→ 717 out = self._runner.run(self._config_cmd + args, **kwargs)
718 return out[‘stdout’], out[‘stderr’]
719

~.conda\envs\naturalistic\lib\site-packages\datalad\cmd.py in run(self, cmd, protocol, stdin, cwd, env, **kwargs)
386 protocol_kwargs=kwargs,
387 cwd=cwd,
→ 388 env=env,
389 )
390 )

~.conda\envs\naturalistic\lib\asyncio\base_events.py in run_until_complete(self, future)
561 “”"
562 self._check_closed()
→ 563 self._check_runnung()
564
565 new_task = not futures.isfuture(future)

~.conda\envs\naturalistic\lib\asyncio\base_events.py in _check_runnung(self)
524 if events._get_running_loop() is not None:
525 raise RuntimeError(
→ 526 ‘Cannot run the event loop while another loop is running’)
527
528 def run_forever(self):

RuntimeError: Cannot run the event loop while another loop is running
"

This should get you going: 9.4. How to get help — The DataLad Handbook

Summary:

>>> import nest_asyncio
>>> nest_asyncio.apply()

>>> import datalad

Thanks for the respond. Now I get a different error. Any idea how to fix it? I forgot to mention that my I am using Anaconda on a windows 10 machine.

import nest_asyncio
nest_asyncio.apply()
import datalad
"

NotImplementedError Traceback (most recent call last)
in
1 import nest_asyncio
2 nest_asyncio.apply()
----> 3 import datalad

~.conda\envs\naturalistic\lib\site-packages\datalad_init_.py in
45
46 from .config import ConfigManager
—> 47 cfg = ConfigManager()
48
49 from .log import lgr

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in init(self, dataset, overrides, source)
272 self._runner = GitWitlessRunner(**run_kwargs)
273
→ 274 self.reload(force=True)
275
276 if not ConfigManager._checked_git_identity:

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in reload(self, force)
325 while to_run:
326 store_id, runargs = to_run.popitem()
→ 327 self._stores[store_id] = self._reload(runargs)
328
329 # always update the merged representation, even if we did not reload

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in _reload(self, run_args)
357 protocol=StdOutErrCapture,
358 # always expect git-config to output utf-8
→ 359 encoding=‘utf-8’,
360 )
361 store = {}

~.conda\envs\naturalistic\lib\site-packages\datalad\config.py in _run(self, args, where, reload, **kwargs)
715 if ‘-l’ in args:
716 # we are just reading, no need to reload, no need to lock
→ 717 out = self._runner.run(self._config_cmd + args, **kwargs)
718 return out[‘stdout’], out[‘stderr’]
719

~.conda\envs\naturalistic\lib\site-packages\datalad\cmd.py in run(self, cmd, protocol, stdin, cwd, env, **kwargs)
386 protocol_kwargs=kwargs,
387 cwd=cwd,
→ 388 env=env,
389 )
390 )

~.conda\envs\naturalistic\lib\site-packages\nest_asyncio.py in run_until_complete(self, future)
96 raise RuntimeError(
97 ‘Event loop stopped before Future completed.’)
—> 98 return f.result()
99 finally:
100 self._thread_id = old_thread_id

~.conda\envs\naturalistic\lib\asyncio\futures.py in result(self)
179 self.__log_traceback = False
180 if self._exception is not None:
→ 181 raise self._exception
182 return self._result
183

~.conda\envs\naturalistic\lib\asyncio\tasks.py in __step(failed resolving arguments)
247 # We use the send method directly, because coroutines
248 # don’t have __iter__ and __next__ methods.
→ 249 result = coro.send(None)
250 else:
251 result = coro.throw(exc)

~.conda\envs\naturalistic\lib\site-packages\datalad\cmd.py in run_async_cmd(loop, cmd, protocol, stdin, protocol_kwargs, **kwargs)
102 try:
103 lgr.debug(‘Launching process %s’, cmd)
→ 104 transport, protocol = await proc
105 lgr.debug(‘Waiting for process %i to complete’, transport.get_pid())
106 # The next wait is a workaround that avoids losing the output of

~.conda\envs\naturalistic\lib\asyncio\base_events.py in subprocess_exec(self, protocol_factory, program, stdin, stdout, stderr, universal_newlines, shell, bufsize, *args, **kwargs)
1542 transport = await self._make_subprocess_transport(
1543 protocol, popen_args, False, stdin, stdout, stderr,
→ 1544 bufsize, **kwargs)
1545 if self._debug and debug_log is not None:
1546 logger.info(’%s: %r’, debug_log, transport)

~.conda\envs\naturalistic\lib\asyncio\base_events.py in _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra, **kwargs)
460 extra=None, **kwargs):
461 “”“Create subprocess transport.”""
→ 462 raise NotImplementedError
463
464 def _write_to_self(self):

NotImplementedError:
"

It works on Anaconda prompt by just saying “import datalad” but when I want to import it in an IDE like spyder and Jupiter notebook it gives me those errors.

I have the same problem.

Are you running Python 3.7? Have a look here, that seems to be the same issue:

Does that help?

1 Like