本文介绍了makemigration导致错误"TypeError:预期的str,字节或os.PathLike对象,而不是NoneType".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在docker容器中运行makemigration命令导致此错误,有人可以帮我找出问题所在吗?

Running makemigration command inside docker container caused this error, can anyone please help me figure out what the problem is ?

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

推荐答案

您正在使用旧版本的 django .

from importlib import import_module
import_module('yourapp.migrations')

import_module的行为在python 3.6(或3.7,我不记得了)中已更改.

import_module behaviour has changed in python 3.6 (or 3.7, I don't remember).

要么改变您的django版本,要么使用python<3.7

Either bump your version of django or use python < 3.7

这篇关于makemigration导致错误"TypeError:预期的str,字节或os.PathLike对象,而不是NoneType".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:30