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

Can't use coverage on Linux

I'm using Linux and I installed coverage by pip3 install coverage, but when I'm type "coverage run file.py" I got "coverage: command not found". Please tell me how to use it the right way... Also I can't do "coverage --version", it will says that command not found...

4 Answers

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

You have to install it first, I have an Ubuntu 14.04 lts in my computer and I install it.

FIrst: (you have to upgrade your pip so it is the last and best version of it) like this:

sudo pip install --upgrade pip

Second: then you can use the "pip" command to install "coverage" like this:

pip install coverage

I hope that helps.

Antonio Rendina
Antonio Rendina
6,968 Points

Maybe you haven't it in your path. In the shell you can type: echo $PATH to see where your shell find executables and: which coverage to see if coverage is in your path. Often /usr/local/bin isn't in the default path, maybe coverage is in /usr/local/bin. In this case you have to modify your .bashrc to accomplish this.

Erika Suzuki
Erika Suzuki
20,299 Points

To make sure you have installed it on your current Python path.

Install it with this command.

python -m pip install coverage
Mike Lucci
Mike Lucci
8,392 Points

Not sure what linux you're running but you can try running the Sudo command

sudo coverage run tests.py