【问题标题】:manage.py createsuperuser: AttributeError: module 'os' has no attribute 'PathLike'manage.py createsuperuser:AttributeError:模块“os”没有属性“PathLike”
【发布时间】:2018-04-05 19:42:47
【问题描述】:

我正在尝试 Django 教程。由于某种原因,我现有的超级用户被删除了;创建它很顺利,但我不能再制作一个。当我尝试使用 pip 时也会发生这种情况。

我没有更改库中的任何内容,所以不确定为什么现在会发生这种情况,但以前没有。在 Windows 7(Python 3.6.3 和 Django 1.11)上。我在 Windows 上看到过类似但不完全相同的问题。我仍然检查了文件,似乎有一个 PathLike 类。

我也尝试修复我的 Python 安装,但没有帮助。有什么想法吗?

【问题讨论】:

  • 请完整的堆栈跟踪?

标签: python django attributeerror


【解决方案1】:

AttributeError: 模块 'os' 没有属性 'PathLike'

使用以下命令将其安装到全局站点包中解决了我的问题:

pip install --user virtualenvwrapper

【讨论】:

    【解决方案2】:

    更新您的 Python 和 Django 版本,这将完美运行。

    【讨论】:

      【解决方案3】:

      这看起来像是 Python3.6 中改变的一个特性,你可以看到 here。确保您的 python 版本是 3.6 或更高版本。

      【讨论】:

        【解决方案4】:

        看来您可能已经修改了 settings.py 文件。但是正如 MrName 提到的,您需要共享完整的堆栈跟踪

        【讨论】:

        • 我尝试用原版替换。没用。这是我在调用并填写 createsuperuser 后得到的结果:文件“C:\Users\ADMIN\AppData\Local\Programs\Python\Python36-32\Lib\gzip.py”,第 52 行,如果 isinstance(filename, (str, bytes, os.PathLike)): AttributeError: module 'os' has no attribute 'PathLike' here's after pip install gzip --upgrade: File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python36 -32\Lib\configparser.py", line 691, in read if isinstance(filenames, (str, os.PathLike)): AttributeError: module 'os' has no attribute 'PathLike' 上帝保佑
        猜你喜欢
        • 2022-07-14
        • 2015-12-17
        • 2020-07-29
        • 1970-01-01
        • 1970-01-01
        • 2013-01-07
        • 2020-02-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多