Skip to main content
 首页 » 编程设计

python之makemigration 导致错误 "TypeError: expected str, bytes or os.PathLike object, not NoneType"

2024年11月24日7over140

在 docker 容器中运行 makemigration 命令导致了这个错误,谁能帮我找出问题所在?

python3.7 manage.py makemigrations 
Traceback (most recent call last): 
  File "/usr/local/lib/python3.7/site-packages/reportlab/lib/utils.py", line 667, in open_for_read 
    return open_for_read_by_name(name,mode) 
  File "/usr/local/lib/python3.7/site-packages/reportlab/lib/utils.py", line 611, in open_for_read_by_name 
    return open(name,mode) 
TypeError: expected str, bytes or os.PathLike object, not NoneType 

请您参考如下方法:

请检查是否缺少 your_app/migrations/__init__.py

如果它不存在,django 可能会抛出这个异常,在这种情况下会抛出 solition

-> 添加__init__.py 再次执行python manage.py makemigrations