Python django 错误 OSError: [WinError 123] 文件名、目录名或卷标语法不正确:'<frozen importlib._bootstrap>'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/56166319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python django error OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
提问by sanif
回答by Ph?m Hoàng
I had the same issue here. After having suffering for a few hours stuck, I figured out the reason. It's very basic. We forgot to run the migrate commands. To fix, run the below commands in order:
我在这里遇到了同样的问题。在忍受了几个小时的痛苦之后,我找到了原因。这是非常基本的。我们忘记运行迁移命令。要修复,请按顺序运行以下命令:
python manage.py migrate
python manage.py makemigrations
python manage.py migrate
While the error notification is not relavance but this fix the error anyway :v.
虽然错误通知不是相关的,但这无论如何都可以修复错误:v。
You can read further information about migration Here.
您可以在此处阅读有关迁移的更多信息。
回答by Buffcoder
I am sensing that you are trying to import bootstrap files for your website.This can be conveniently done by adding the hyperlink from the bootstrap cdn on your base template. Also you can download the boostrap package and copy the css and js files under the static folder in your project.
我感觉到您正在尝试为您的网站导入引导程序文件。这可以通过在您的基本模板上添加引导程序 CDN 中的超链接来方便地完成。也可以下载boostrap包,复制项目中静态文件夹下的css和js文件。
回答by Francisco de Larra?aga
In my case, I was missing the \
when using multiple lines to import:
就我而言,我错过了\
使用多行导入时的内容:
from .models import Country, State, Locality, Address,\
PercentageAmount, Condominium, Condominium_expenses_report,\
FunctionalUnit, Percentage, FunctionalUnit_expenses_report,\
Expense, Bill, Judgment, Insurance, Concept
回答by Phanti
I had the same error and I also do not have any bootstrap included in my application. In my case the virtualenv server stopped running. Just reboot the Django server and you are good to go again.
我有同样的错误,我的应用程序中也没有包含任何引导程序。在我的情况下,virtualenv 服务器停止运行。只需重新启动 Django 服务器,您就可以再次使用。
回答by 40Sherrin
I made the same mistake and to solve the issue try this
我犯了同样的错误,要解决这个问题试试这个
from django.http import HttpResponse
回答by fredatwira
first but not always, it seems you have deleted a file/folder from your project. if so, remember to delete the path that was serving that folder "path in the project urls.py"
首先但并非总是如此,您似乎已从项目中删除了一个文件/文件夹。如果是这样,请记住删除为该文件夹提供服务的路径“项目 urls.py 中的路径”
回答by Arthur
if you have virtualenv managing your packages make sure that is activated it before you run your app.
如果您使用 virtualenv 管理您的包,请确保在运行应用程序之前将其激活。
回答by Ziar Khan
The same issue is also occurred when someone misspell filename, directory name or app name... for example when someone create an app by the name of users and then he/she want to enlist the app in the INSTALLED_APPS List available in the setting.py file in misspell way like ............ users.app.UsersConfig instead of users.apps.UsersConfig
当有人拼错文件名、目录名或应用程序名称时,也会出现同样的问题……例如,当有人通过用户名创建应用程序,然后他/她想在设置中可用的 INSTALLED_APPS 列表中登记应用程序时。 py 文件以拼写错误的方式,如 ............ users.app.UsersConfig 而不是 users.apps.UsersConfig