Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

I can't get python `coverage` to work in the team treehouse portal

When I type coverage run tests.py during tutorials errors occur as below. I would appreciate a steer on how to get this working.

Error details:

treehouse:~/workspace/dice$ coverage run tests.py
Traceback (most recent call last):
File "/usr/local/bin/coverage", line 33, in <module>
sys.exit(load_entry_point('coverage==4.0.3', 'console_scripts', 'coverage')())
File "/usr/local/bin/coverage", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/local/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module
return bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/lib/python3.9/site-packages/coverage/
init_.py", line 13, in <module>
from coverage.control import Coverage, process_startup
File "/usr/local/lib/python3.9/site-packages/coverage/control.py", line 30, in <module>
from coverage.python import PythonFileReporter
File "/usr/local/lib/python3.9/site-packages/coverage/python.py", line 11, in <module>
from coverage.parser import PythonParser
File "/usr/local/lib/python3.9/site-packages/coverage/parser.py", line 320, in <module>
OP_BREAK_LOOP = _opcode('BREAK_LOOP')
File "/usr/local/lib/python3.9/site-packages/coverage/parser.py", line 278, in _opcode
return dis.opmap[name]
KeyError: 'BREAK_LOOP'

Chris Freeman
Chris Freeman
Treehouse Moderator 68,426 Points

also could you create a snapshot of you workspace using the camera icon in the upper right, then post the link created?

Lars Holmberg
Lars Holmberg
19,949 Points

I'm encountering the same problem in the Using Coverage module.

Here's a snapshot of the workspace as was requested.

And the Error I'm encountering when I try to run coverage run tests.py:

treehouse:~/workspace/dice$ coverage run tests.py
Traceback (most recent call last):
File "/usr/local/bin/coverage", line 33, in <module>
sys.exit(load_entry_point('coverage==4.0.3', 'console_scripts', 'coverage')())
File "/usr/local/bin/coverage", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/local/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module
return bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/lib/python3.9/site-packages/coverage/
init_.py", line 13, in <module>
from coverage.control import Coverage, process_startup
File "/usr/local/lib/python3.9/site-packages/coverage/control.py", line 30, in <module>
from coverage.python import PythonFileReporter
File "/usr/local/lib/python3.9/site-packages/coverage/python.py", line 11, in <module>
from coverage.parser import PythonParser
File "/usr/local/lib/python3.9/site-packages/coverage/parser.py", line 320, in <module>
OP_BREAK_LOOP = _opcode('BREAK_LOOP')
File "/usr/local/lib/python3.9/site-packages/coverage/parser.py", line 278, in _opcode
return dis.opmap[name]
KeyError: 'BREAK_LOOP'

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,426 Points

The issue appears to be the workspace requires version coverage==4.0.3 but this version is not comparable with Python 3.9.0.

According to the coverage release page needs to be updated to version 5.5

You can try:

$ pip install coverage==5.5

This got me passed the error above.

Post back with your results.

Dev Team: please make coverage==5.5 the default for Python 3.9 workspaces.

Lars Holmberg
Lars Holmberg
19,949 Points

That solved the issue perfectly, thank you!