简体   繁体   中英

Python 'cannot import name 'TestCase'' When importing unittest

Whenever I attempt:

import unittest

I get the following error:

 Traceback (most recent call last):
  File "wackyTesting.py", line 1, in <module>
    import unittest
  File "C:\.....\Python\Python36\lib\unittest\__init__.py", line 59, in <module>
    from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
ImportError: cannot import name 'TestCase'

This happens regardless of where the code is run, there is nothing in the root that could be causing a conflict. I have tried re-installing unittest but it didn't help. It was working perfectly until just recently. Any ideas?

Welp, I just uninstalled python completely and reinstalled. Nothing quite like turning it off and on again. That seems to have done it, maybe there's a more elegant solution but this will have to do for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM