-1

I have a Django application, which very suddenly started giving me an error. I made a code change, restarted the application, and now I can't get rid of this error. I really don't think that I did anything else in between the two runs.

The error is ImportError: "No module named unittest" I don't know if it thinks it should be running a unit test or if this just happens to be the first thing to fail.

I have tried running it both from Eclipse and from the CMD line with manage.py runserver. Same error. (This is an update. previously I had only tried from Eclipse.) A brand-new project made in Eclipse has the same error.

This happens with any web application (using runserver), so it's not my code. I also reverted back to older code that worked fine before.

I have tried restarting my computer.

I am able to run "regular'(not a web application) python programs from the cmd line. So it does find Python.

I honestly have no idea what to do at this point, except to reinstall Python, which I'd like to avoid. Anyone?

NEW Stack trace (Update: previous was from Eclipse and just showed pydev errors. Run from cmd line it shows more python.)

Validating models...

Unhandled exception in thread started by <bound method Command.inner_run of <django.core.management.commands.runserver.Command object at 0x02FE2710>>
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 93, in inner_run
    self.validate(display_num_errors=True)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 280, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\Python27\lib\site-packages\django\core\management\validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 166, in get_app_errors
    self._populate()
  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 75, in _populate
    self.load_app(app_name)
  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 96, in load_app
    models = import_module('.models', app_name)
  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Python27\lib\site-packages\django\contrib\auth\models.py", line 18, in <module>
    from django.contrib.auth.hashers import (
  File "C:\Python27\lib\site-packages\django\contrib\auth\hashers.py", line 8, in <module>
    from django.test.signals import setting_changed
  File "C:\Python27\lib\site-packages\django\test\__init__.py", line 6, in <module>
    from django.test.testcases import (TestCase, TransactionTestCase,
  File "C:\Python27\lib\site-packages\django\test\testcases.py", line 35, in <module>
    from django.test import _doctest as doctest
  File "C:\Python27\lib\site-packages\django\test\_doctest.py", line 104, in <module>
    import unittest, difflib, pdb, tempfile
ImportError: No module named unittest
user984003
  • 28,050
  • 64
  • 189
  • 285

2 Answers2

0

Well, don't know if I'd call it an answer, but I reinstalled Python and now it's working. Now I just have to reinstall my 10 or so libraries to fix the runtime errors.

user984003
  • 28,050
  • 64
  • 189
  • 285
0

unittest module is integral part of python, which causes import error when django tries to import it. You must have somehow deleted some python package, or have corrupted installation.

hspandher
  • 15,934
  • 2
  • 32
  • 45