开发者

Error in eclipse, when import coverage?

in mac terminal

$ coverage help
Coverage.py, version 3.5

Measure, collect, and report on code coverage in Python programs.

While in the eclipse, I encounter error as follows: please give a hand

Error: coverage module could not be imported
Please make sure that the coverage module (http://nedbatchelder.com/code/coverage/)
is properly installed in your interpreter: /usr/bin/python
Traceback (most recent call last):
  File "/Users/***/eclipse/plugins/org.python.pydev.d开发者_高级运维ebug_2.2.0.2011062419/pysrc/pydev_coverage.py", line 34, in execute
    import coverage #@UnresolvedImport
ImportError: No module named coverage


Make sure you have the correct PYTHONPATH variable set in your project settings. To set the path right click on the project in the package explorer and open Properties. Under PyDev - PYTHONPATH you should find the entries, which have to be set to the correct locations.


I had the similar problem with the OP.

I'm using PyDev 2.6 with Eclipse 3.7.2 on Mac OS X Mountain Lion. The python version I've been using was python2.7.2 under

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

I had to set my Python interpreter right to let get coverage working. Apparently the coverage was installed to be used with that version of Python.

The Steps I took to solve my problem:

  1. Go to Preferences | PyDev | Interpreter - Python; After installing PyDev, there should be already /usr/bin/python there in the interpreter list.
  2. Click New..., Add /Library/Frameworks/Python.framework/Versions/2.7/bin/python; Check the path item with "pysrc" in it, usually the first one when you are prompted to select modules to import.
  3. Place the newly added interpreter to the top of the list.
  4. Click OK and quit Preferences.

Run your test again and the error should be gone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜