Ex46 - nosetests error

Hi all,

I am working on Exercise 46 of Learn Python the Hard Way, and I’m stuck on running nosetests.
The error I get is an AttributeError where it says the module ‘collections’ has no attribute ‘Callable’. Pasting below for your reference.

(lpthw) PS C:\Users\Admin\projects\skeleton> nosetests
Traceback (most recent call last):
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py”, line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\runpy.py”, line 86, in run_code
exec(code, run_globals)
File "C:\Users\Admin.venvs\lpthw\Scripts\nosetests.exe_main
.py", line 7, in
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\core.py”, line 118, in init
unittest.TestProgram.init(
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\unittest\main.py”, line 100, in init
self.parseArgs(argv)
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\core.py”, line 179, in parseArgs
self.createTests()
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\core.py”, line 193, in createTests
self.test = self.testLoader.loadTestsFromNames(self.testNames)
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\loader.py”, line 481, in loadTestsFromNames
return unittest.TestLoader.loadTestsFromNames(self, names, module)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\unittest\loader.py”, line 220, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\unittest\loader.py”, line 220, in
suites = [self.loadTestsFromName(name, module) for name in names]
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\loader.py”, line 454, in loadTestsFromName
return LazySuite(
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\suite.py”, line 53, in init
super(LazySuite, self).init()
File “C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\unittest\suite.py”, line 22, in init
self._tests = []
File “C:\Users\Admin.venvs\lpthw\lib\site-packages\nose\suite.py”, line 106, in _set_tests
if isinstance(tests, collections.Callable) and not is_suite:
AttributeError: module ‘collections’ has no attribute ‘Callable’
(lpthw) PS C:\Users\Admin\projects\skeleton>

I’ve been stuck here for a while now, so appreciate any help and guidance on this.

1 Like

Use pytest instead. Nose is no longer maintained. You’ll find lots of threads about this here.

For anyone else who comes up against this, you can also install nosetests this way, and it then works with Python 3.10

pip install nose-py3