I ran the command pip install coverage and it appears to have installed correctly.
Frodo:Triangle567 tarikkdiry$ pip install coverage
Collecting coverage
Using cached https://files.pythonhosted.org/packages/c7/d0/337673c08f5b0cc7ada3dfe2a998ae8a97d482722045644be3d79bbcbe05/coverage-4.5.1-cp37-cp37m-macosx_10_13_x86_64.whl
Installing collected packages: coverage
Successfully installed coverage-4.5.1
However, after running coverage on one of my test files, I receive this error:
Frodo:Triangle567 tarikkdiry$ coverage run testtriangle.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/coverage", line 7, in <module>
from coverage.cmdline import main
ModuleNotFoundError: No module named 'coverage.cmdline'; 'coverage' is not a package
Frodo:Triangle567 tarikkdiry$
I have tried uninstalling every python package and reinstalling but to no success. I have tried this on another machine and can confirm the test file is working properly.
EDIT: After running pip3 check coverage and pip3 show coverage
pip3 check coverage:
No broken requirements found.
pip3 show coverage
Name: coverage
Version: 4.5.1
Summary: Code coverage measurement for Python
Home-page: https://bitbucket.org/ned/coveragepy
Author: Ned Batchelder and 100 others
Author-email: [email protected]
License: Apache 2.0
Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Requires:
Required-by:
You should check if coverage refer to python or python3. Most likely it uses python to run exact tool you need. Default python version on macOS is python 2.7.
Another option is to create a virtual environment by running python3.7 -m venv $directory (where $directory contains a folder for virtual environment, you can use direct paths as you wish), then activating it by running source $directory/bin/activate. After doing this, you'll have no problems finding all packages you want. I personally prefer this method over installing packages into the system.
Additionally, you can install python3.7 from MacPorts or Homebrew and activate it as a default python. For many libraries you can install them using these package managers as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With