Reputation: 4797
When I try to create an initial database for my Django app using manage.py
syncdb
, it crashes at the point where I'm about to create the super user, after entering the email address:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/getpass.py", line 114, in fallback_getpass
stacklevel=2)
getpass.GetPassWarning: Can not control echo on the terminal.
What I've tried to solve this:
Skipping the creation of the super user during syncdb
and run the createsupercommand
. This appears to solve the problem as there is a superuser created however it's impossible to log in to the admin site
with that user id and password.
Deleting and recreating the database.
Double checked the user profile in the database: user name, password, is_staff, is_active all have the correct values.
Debugged the process until I actually see the correct user name and password being passed into the authenticate
function.
Checked database encoding which is set to UTF-8.
I use Django 1.6.5, Pycharm and MySQL. The whole thing is rather baffling as my other projects with identical setup work flawless.
Any ideas as to what might be causing this?
EDIT: Apparently during the botched superuser creation, Django somehow marks the password as being unusable (which is impossible to detect as the hash is stored in the db and uninterpretable for humans). I managed to circumvent this by creating a password hash outside the Django environment and pasting that in the database. At least it allows me to login now. Problem not yet solved though...
Upvotes: 2
Views: 564
Reputation: 499
For future readers of this thread:
This issue was also seen with Django 2.06, Python 3.6.1, Win 7 SP1, with PyCharm 2018.1 as well.
Partial traceback:
File "..\django\contrib\auth\management\commands\createsuperuser.py", line 145, in handle password = getpass.getpass()
File "C:\Program Files (x86)\Python36-32\lib\getpass.py", line 122, in fallback_getpass
getpass.GetPassWarning: Can not control echo on the terminal.
Got resolved based on suggestion by @vlad-ardelean earlier in this thread:
(i) Open a Windows terminal (within PyCharm is fine)
(ii) cd to the Django project directory containing manage.py
(iii) manage.py createsuperuser
Upvotes: 0
Reputation: 7622
On Ubuntu, the getpass
library, does this
# Bind the name getpass to the appropriate function
try:
import termios
# it's possible there is an incompatible termios from the
# McMillan Installer, make sure we have a UNIX-compatible termios
termios.tcgetattr, termios.tcsetattr
except (ImportError, AttributeError):
try:
import msvcrt
except ImportError:
try:
from EasyDialogs import AskPassword
except ImportError:
getpass = fallback_getpass
else:
getpass = AskPassword
else:
getpass = win_getpass
else:
getpass = unix_getpass
Your problem seems to be cause by the fact that the getpass
library can't import one of the 3 libraries it wants to use for reading user input in a non-echo way.
I realize you're using Mac, and i dunno if this will differ, but if getpass is the same as mine, you'll need to make sure you have the terminos
, msvcrt
or EasyDialogs
installed;
This post on stackoverflow tells you how to install packages on Mac.
you can basically run the commands: easy_install pip
and after that pip install terminos
(and if this doesn't do it, try installing msvcrt or EasyDialogs).
[EDIT] the msvcrt
library is just for windows, don't mind that.
Upvotes: 2