Chapter 15: ImportError: No module named 'accounts'

2,276 views
Skip to first unread message

Kifsif

unread,
Apr 21, 2016, 7:54:30 AM4/21/16
to Obey the testing goat! Test-Driven Web Development with Python book
I'm here: http://chimera.labs.oreilly.com/books/1234000000754/ch15.html#_reverting_our_spiked_code

I've executed:

rm -rf accounts # remove any trace of spiked code

And now I am supposed to do:
python3 manage.py test functional_tests.test_login

But I get:
michael@michael:~/Tdd/superlists$ python3 manage.py test functional_tests.test_login
Traceback (most recent call last):
 
File "manage.py", line 10, in <module>
    execute_from_command_line
(sys.argv)
 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility
.execute()
 
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 312, in execute
    django
.setup()
 
File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup
    apps
.populate(settings.INSTALLED_APPS)
 
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 85, in populate
    app_config
= AppConfig.create(entry)
 
File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 86, in create
   
module = import_module(entry)
 
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
   
return _bootstrap._gcd_import(name[level:], package, level)
 
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
 
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
 
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'accounts'

Well, the reason seems to be in settings.py.

In INSTALLED_APPS I comment 'accounts' out. 

Start the test again. Now tons of garbage traceback information is rains over me. In the book it is just one line: NoSuchElementException

I had to copy all the traceback info and paste it into a text editor and look for it via Ctrl+f. Nothing.

Then in settings.py I had to comment out:
# AUTH_USER_MODEL = 'accounts.User'
# AUTHENTICATION_BACKENDS = (
#     'accounts.authentication.PersonaAuthenticationBackend',
# )

And now I can see NoSuchElementException

Am I correct that everybody have to manipulate things like me?
If yes, I would say it is not convenient for a reader. 

The reader of the book is a beginner. Wouldn't it be better if all the steps in the book were explicit and reproduced symbol by symbol?

Please, pardon me if I'm wrong with that introductory assumption that everybody has to comment something out which is not mentioned in the book.

Harry Percival

unread,
Apr 21, 2016, 8:35:47 AM4/21/16
to Kifsif, Obey the testing goat! Test-Driven Web Development with Python book
Hi there,

I think the "git checkout master" command that I say to run before "rm -rf accounts" should have removed those lines from your settings.py.  Did you definitely do that git checkout?  is it possible you made a mistake with some of the earlier git branching, or other commits?

rgds,
Harry


--
You received this message because you are subscribed to the Google Groups "Obey the testing goat! Test-Driven Web Development with Python book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to obey-the-testing-go...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kifsif

unread,
Apr 21, 2016, 11:02:32 AM4/21/16
to Obey the testing goat! Test-Driven Web Development with Python book, nonv...@gmail.com
Thank you for the answer. 

Maybe. I can't reconstruct it now. Judged by the symptoms it is most probable. 
I have to redo the whole chapter. 

Thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to obey-the-testing-goat-book+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages