django-admin startproject创建损坏的manage.py文件

发布于 2025-02-09 22:22:26 字数 1517 浏览 3 评论 0原文

无视,我不能在两天内关闭。

我也尝试使用Virtualenv也没有运气,我知道对“ Python -M Venv .Env”有一个偏爱,但这不太可能是问题。

Django和虚拟环境在过去的机器上也很好。

创建的Manage.py文件:

#!/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()

重新创建的步骤:

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

似乎正常工作,

pip install django, django-rest-framework, etc

查看所有内容并再次运行命令,它似乎安装了正常。使用Django 3和4相同的结果尝试了此操作

django-admin startproject backend .

(有或不指定当前目录,对此进行了测试) 无论我做什么,我都会在上面获取manage.py文件。 “哪个python”和“ django -admin”指出了

'python -c“导入sys; print(sys.path)的ENV”'''

['', '/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']

对于为什么继续被打破的原因绝对失去了。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜清冷一曲。 2025-02-16 22:22:26

哎呀,已经有一段时间了,我把managy.py与settings.py混淆了,在想所有这些东西都在内部manage.py。实际上一切正常。如果可以的话,请关闭它,因为该网站不会让我。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文