Error when doing brian2.test()

Description of problem

I’m doing a test on newly installed brian2 but have the following errors. Any inputs are appreciated.
Thanks
–Wei
/////////////////////////////////////////////////////////
Python 3.8.5 (default, Aug 5 2020, 08:36:46)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import brian2
brian2.test()
Running tests in /home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/brian2 for targets numpy, cython (excluding long tests)
Running Brian version 2.3.0.2 from ‘/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/brian2’
Testing codegen-independent code
Resetting to default preferences

Running doctests
ERROR Brian 2 encountered an unexpected error. If you think this is bug in Brian 2, please report this issue either to the mailing list at http://groups.google.com/group/brian-development/, or to the issue tracker at https://github.com/brian-team/brian2/issues. Please include this file with debug information in your report: /tmp/brian_debug_n3a2_sma.log Thanks! [brian2]
Traceback (most recent call last):
File “”, line 1, in
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/brian2/tests/init.py”, line 320, in run
success.append(pytest.main(argv + additional_args,
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/init.py”, line 136, in main
config = _prepareconfig(args, plugins)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/init.py”, line 313, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/pluggy/hooks.py”, line 286, in call
return self._hookexec(self, self.get_hookimpls(), kwargs)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/pluggy/manager.py”, line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/pluggy/manager.py”, line 84, in
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/pluggy/callers.py”, line 203, in _multicall
gen.send(outcome)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/helpconfig.py”, line 99, in pytest_cmdline_parse
config = outcome.get_result() # type: Config
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/pluggy/callers.py”, line 80, in get_result
raise ex[1].with_traceback(ex[2])
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/pluggy/callers.py”, line 187, in _multicall
res = hook_impl.function(*args)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/init.py”, line 932, in pytest_cmdline_parse
self.parse(args)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/init.py”, line 1204, in parse
self._preparse(args, addopts=addopts)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/init.py”, line 1085, in _preparse
self._initini(args)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/init.py”, line 1002, in _initini
ns, unknown_args = self._parser.parse_known_and_unknown_args(
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/argparsing.py”, line 157, in parse_known_and_unknown_args
optparser = self._getparser()
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/argparsing.py”, line 112, in _getparser
optparser = MyOptionParser(self, self.extra_info, prog=self.prog)
File “/home/wxie/.conda/envs/cent7/5.3.1-py37/brian2/lib/python3.8/site-packages/_pytest/config/argparsing.py”, line 380, in init
argparse.ArgumentParser.init(
TypeError: init() got an unexpected keyword argument ‘allow_abbrev’

Minimal code to reproduce problem

None

What you have aready tried

I tried to down grade python from 3.8 to 3.7 but it failed.

Expected output (if relevant)

Actual output (if relevant)

Full traceback of error (if relevant)

I think this error indicates that for some reason you have an old argparse package installed. Could you check (e.g. with conda list|grep argparse)? This package should not be necessary at all anymore, since argparse is part of Python’s standard library since Python 3.5.

Thanks Marcel. That’s indeed the case. Somehow in my PYTHONPATH I still have the old path to argparse. After removing it, the brian2.test() runs fine.

1 Like