【问题标题】:AttributeError: 'NoneType' object has no attribute 'connect'AttributeError:“NoneType”对象没有属性“连接”
【发布时间】:2021-06-15 22:36:52
【问题描述】:

我在 Python 2.7 上运行 Trac 1.2.2,在 Ubuntu 18.04 上使用 MariaDB,我现在必须迁移到 Ubuntu 20.04。我知道不再支持 Python 2.7,但我仍然需要在我的 Ubuntu 20.04 服务器上运行它,因为我运行的是旧版本的 Trac,由于插件无法在最新版本中运行,我现在无法升级版本...

所以我迁移了 MariaDB 数据库,在 this comment 的帮助下安装了 MySQL-python,现在在 Trac 的调试模式下出现以下错误:

2021-03-18 10:16:31,836 Trac[main] ERROR: can't retrieve session: TimeoutError: Unable to get database connection within 0 seconds. (AttributeError: 'NoneType' object has no attribute 'connect')

知道我可能错过了什么吗?

【问题讨论】:

  • 在这张票 trac.edgewall.org/ticket/9916 中,这个家伙通过修复文件权限(奇怪地)解决了问题。
  • 感谢您的提示,但不幸的是,我的 tracenv 已经归 www-data 拥有:-/
  • @michael-ruth 瞧 ;-)
  • @Andreas,请发布产生此错误的代码。该错误表明调用connect() 方法实际上是None

标签: mysql python-2.7 mariadb mysql-python


【解决方案1】:

我能够自己解决这个问题。来自this comment 的文件在 Ubuntu 20.04 下无法正常工作

我将文件 my_config.h 从 Ubuntu 18.04 安装复制到我的 Ubuntu 20.04 到 /usr/include/mysql 中,然后再次 pip install MySQL-python,现在一切正常:-)

【讨论】:

    猜你喜欢
    • 2019-01-01
    • 2021-12-26
    • 2019-07-23
    • 2018-05-13
    • 2020-09-07
    • 2017-05-03
    • 2023-03-16
    • 2018-07-14
    • 2013-06-16
    相关资源
    最近更新 更多