How to fix No common-passwords.txt.gz error in Django when trying to createsuperuser

Using a Django installation repl, when I try to run

python manage.py createsuperuser

I get an error that is basically

FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.cache/pip/pool/94/b4/cf/common-passwords.txt.gz'

Navigating to the directory indeed the common passwords file is missing.

Appreciate advice on:

  1. Is this a common problem on Django repls?
  2. How do I fix this error in my repl?

Thanks.

Hey, @kwloong welcome to the forums!

Can you please provide a link to the repl? This way it is easier for staff and members of the community to help you!

Also see this guide on how to share your code:

2 Likes

Thanks, recreated repl and problem did not resurface.

Good for you!

But how come? I created several repls and the issue kept showing up every single time.
I tried to create Django repl, installed Wagtail, and I got this issue. I also even tried to create a plain Python repl, installed Django/Wagtail, and ended up with the same issue as well.

Could you please explain?

Hi @kwloong !
Since I did not solve the problem, could you change the Solution to your post instead?
Thanks!
@QwertyQwerty88 can you change it? Tysm.

Did a bit more troubleshooting. Turns out problem still exist.

Using a “Django” repl template, could create superuser

But…
Using a “python” repl template and running

pip install django
django-admin startproject testErrorInDjango
python manage.py startapp testErrorApp
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

The createsuperuser command will fail after keying in the necessary info (user, email, password)

Link to Repl:
https://replit.com/@kwloong/TestErrorInDjango

Error:

Traceback (most recent call last):
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py”, line 236, in **init**
with gzip.open(password_list_path, “rt”, encoding=“utf-8”) as f:
File “/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/gzip.py”, line 58, in open
binary_file = GzipFile(filename, gz_mode, compresslevel)
File “/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/gzip.py”, line 174, in **init**
fileobj = self.myfileobj = builtins.open(filename, mode or ‘rb’)
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/runner/.cache/pip/pool/94/b4/cf/common-passwords.txt.gz’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/runner/TestErrorInDjango/testErrorInDjango/manage.py”, line 22, in
main()
File “/home/runner/TestErrorInDjango/testErrorInDjango/manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/core/management/**init**.py”, line 442, in execute_from_command_line
utility.execute()
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/core/management/**init**.py”, line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/core/management/base.py”, line 412, in run_from_argv
self.execute(*args, **cmd_options)
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/management/commands/createsuperuser.py”, line 88, in execute
return super().execute(*args, **options)
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/core/management/base.py”, line 458, in execute
output = self.handle(*args, **options)
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/management/commands/createsuperuser.py”, line 183, in handle
validate_password(password2, self.UserModel(**fake_user_data))
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py”, line 50, in validate_password
password_validators = get_default_password_validators()
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py”, line 22, in get_default_password_validators
return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py”, line 36, in get_password_validators
validators.append(klass(**validator.get(“OPTIONS”, {})))
File “/home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py”, line 239, in **init**
with open(password_list_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/runner/.cache/pip/pool/94/b4/cf/common-passwords.txt.gz’

The file common-passwords.txt.gz is at /home/runner/TestErrorInDjango/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth , which I understand is typical for django installs.
(older repls would be somewhere under venv subdirectory?)

Can’t figure out why it’s going to the cache (/home/runner/.cache/pip/pool/) to find common-passwords.txt.gz

Thanks.

1 Like

Exactly! The problem is really annoying and pushes me to give up on Replit altogether… :face_with_diagonal_mouth:

Hey @kwloong and @OmarAbdulHafiz!

Python Repls are configured to work with poetry instead of pip. You can run poetry add django to install the package in the Repl. Also, you can use our Packager tool to install packages in a GUI.

Docs on our Packager, auto-guesser, and other package-related features here: https://docs.replit.com/programming-ide/installing-packages

Hi Shane!

Thanks for the clarification. However, even installing Django/Wagtail through poetry instead of pip does not solve the “common-passwords.txr.gz file not found” issue.

There seems to be some other cause behind this strange problem.:person_shrugging:

Thanks

Omar

pip uninstall django

and then reinstalled django using the replit pacakage manager

Error persists.

Created a new repo
https://replit.com/@kwloong/TestErrorInDjango02

and installed django using the replit package manager ui
did the same thing:

django-admin startproject testErrorInDjango02
python manage.py startapp testErrorApp
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

Got similar error (reproduced below):

File "/home/runner/TestErrorInDjango02/testErrorInDjango02/manage.py", line 22, in <module>
    main()
  File "/home/runner/TestErrorInDjango02/testErrorInDjango02/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 88, in execute
    return super().execute(*args, **options)
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 183, in handle
    validate_password(password2, self.UserModel(**fake_user_data))
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py", line 50, in validate_password
    password_validators = get_default_password_validators()
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py", line 22, in get_default_password_validators
    return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py", line 36, in get_password_validators
    validators.append(klass(**validator.get("OPTIONS", {})))
  File "/home/runner/TestErrorInDjango02/.pythonlibs/lib/python3.10/site-packages/django/contrib/auth/password_validation.py", line 239, in __init__
    with open(password_list_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.cache/pip/pool/94/b4/cf/common-passwords.txt.gz'

Please advise. Thanks,

any updates? Thanks.

Hey @kwloong! Could you try this:

Just click the next to “Files” then click “Show hidden files”. Next click on the .replit file and finally you can change the entrypoint to manage.py?

Images

Dots

Show hidden files

edited

You should also see the docs on how to configure a Repl: https://docs.replit.com/programming-ide/configuring-repl

And if you want to run the last edited file, take a look at this post:

Then, try the createsuperuser command again?

@NateDhaliwal Thank you very much for this interesting solution!

But it didn’t work for me either. Could it be something that I’m doing wrong? :thinking:

Here’s the link to my repl for your reference: https://replit.com/@OmarAbdulHafiz/SeriousCarelessGlitches

Please help…

Hi @OmarAbdulHafiz , @kwloong !
Do you have django.contrib.admin inside your repl?

Also, @OmarAbdulHafiz , by using Secrets, some things won’t run if we use it from the Cover Page (website is fine). Additionally, could you change the .replit file from ./manage.py to /mysite/manage.py?

@kwloong Please please please keep the Django key in Secrets!
Avoid putting it visibly, where people may misuse it!

Could you please explain the Secrets part a bit further?

Also, I think I do have “django.contrib.admin” inside my repl, but how do I make sure?

From a quick glance at where Django is trying to read that passwords file from, try running this in Shell:

cp -r .cache ../.cache

Though do note that you’ll have to run this each time your Repl restarts. (Assuming it works)

1 Like

This is what I got:

~/SeriousCarelessGlitches/mysite$ cp -r .cache ../.cache
cp: cannot stat '.cache': No such file or directory
Detected change in environment, reloading shell...

1 Like

Oh, you’re in a subfolder, try this instead:

cp -r /home/runner/$REPL_SLUG/.cache /home/runner/.cache
1 Like