简体   繁体   中英

Django-admin startproject creates broken manage.py file

Disregard, I can't close this for 2 days though.

I've tried this using virtualenv as well with no luck as well, I know there's a preference against "python -m venv .env" but that is very unlikely to be the issue.

Django and virtual environments have worked fine in the past on this machine as well.

The manage.py file created:

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'firebackend.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()

steps to recreate:

python -m venv .env 
source .env/bin/activate

Appears to be working normal

pip install django, django-rest-framework, etc

Looking at everything and running the command again it appears to install fine. Tried this with Django 3 and 4 same results

django-admin startproject backend .

(with or without specifying the current directory, tested that out) And no matter what I do I get the manage.py file above. "Which python" and "which django-admin" point to the env

result of 'python -c "import sys; print(sys.path)"'

['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/user/Documents/fire-agency-directory/.env/lib/python3.8/site-packages']

Absolutely lost as to why it continues to be broken.

Whoops, it's been a while and I confused manage.py with settings.py, was thinking all that stuff was inside manage.py. Everything is actually working just fine. Please close this if you can because the site will not let me.

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