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 Python Testing Covering Your Bases Using Coverage

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

[SOLVED]Still having problem with coverage

The coverage run tests.py comand still throw me errors.

I follow the steps find in this post but seems not working.

bash: /home/treehouse/.local/bin/coverage: /usr/local
/pyenv/versions/3.4.1/bin/python3.4: bad interpreter:
 No such file or directory 

I already try pip install coverage and pip install --upgrade coverage but the things are't changed.

I see that is a common issue, so I just report here, or maybe there's a solution?

Thanks in advance!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

In some cases, starting a fresh workspace fixes it. The file structure on some of the older workspaces is not compatible with using the simple --upgrade or install solution. If you haven't yet, try working through the many steps of the Best Answer for the post you linked to and post back where it fails for you.

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Thanks Chris,

I try and let you know!

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Speak too far, today I've try to delete and re-create the workspace and it works.

I've try right now, always with a new workspace, but with the error that I posted above.

So I try your procedure in post linked but throw me this error:

Traceback (most recent call last):                                
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 651, in _build_master          
    ws.require(__requires__)                                      
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 952, in require                
    needed = self.resolve(parse_requirements(requirements))       
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 844, in resolve                
    raise VersionConflict(dist, req).with_context(dependent_req)  
pkg_resources.VersionConflict: (coverage 4.0.3 (/usr/local/pyenv/v
ersions/3.5.0/lib/python3.5/site-packages), Requirement.parse('cov
erage==3.7.1'))                                                   

During handling of the above exception, another exception occurred
:                                                                 

Traceback (most recent call last):                                
  File "/home/treehouse/.local/bin/coverage", line 5, in <module> 
    from pkg_resources import load_entry_point                    
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 3084, in <module>              
    @_call_aside                                                  
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 3070, in _call_aside           
    f(*args, **kwargs)                                            
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 3097, in _initialize_master_wor
king_set                                                          
    working_set = WorkingSet._build_master()                      
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 653, in _build_master          
    return cls._build_from_requirements(__requires__)             
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 666, in _build_from_requirement
s                                                                 
    dists = ws.resolve(reqs, Environment())                       
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-package
s/pkg_resources/__init__.py", line 839, in resolve                
    raise DistributionNotFound(req, requirers)                    
pkg_resources.DistributionNotFound: The 'coverage==3.7.1' distribu
tion was not found and is required by the application

:grin:

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Thanks for the details. Can you snapshot your workspace using the icon in the upper right, then post the link to the snapshot?

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

When I try to fork it it returns me "There was a problem forking this workspace." I'll post you the link: https://teamtreehouse.com/workspaces/15588262#

edit:

I press the wrong button :sweat_smile: here's the link, sorry! http://w.trhou.se/ocx0e1ukn4

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

You have uncovered an workspaces environment error. The issue is there are two coverage executables. In the older workspaces the directory ~/.local/bin is ahead of the /usr/local/pyenv/shims. The version in the ~/.local/bin is old and can be removed.

To create a workaround:

# check currently run executable location
treehouse:~/workspace$ which coverage
~/.local/bin/coverage

# rename coverage
treehouse:~/workspace$ cd ~/.local/bin
treehouse:~/.local/bin$ ls
coverage  coverage3  coverage-3.4
treehouse:~/.local/bin$ mv coverage coverage.old


# recheck currently run executable location
treehouse:~/.local/bin$ which coverage
/usr/local/pyenv/shims/coverage

# rehash bash executable locations
treehouse:~/.local/bin$ hash -r

# test run coverage
treehouse:~/.local/bin$ coverage --version
Coverage.py, version 4.0.3.
Documentation at https://coverage.readthedocs.org
Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

That's work! (as surely already you know! :sweat_smile: )

First, thanks for your time!

There the need to communicate this issue at the support team?