You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决AttributeError: 'version_info' object has no attribute '__version__'错误

问题解决:Carla Simulator运行module_7.py时的pyparsing版本错误

报错详情

运行module_7.py时触发以下错误:

C:\Coursera\CarlaSimulator\PythonClient\Course1FinalProject>python module_7.py
Traceback (most recent call last):
  File "module_7.py", line 26, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\__init__.py", line 131, in <module>
    from matplotlib.rcsetup import defaultParams, validate_backend, cycler
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\rcsetup.py", line 29, in <module>
    from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\fontconfig_pattern.py", line 22, in <module>
    from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd,
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\pyparsing\__init__.py", line 130, in <module>
    __version__ = __version_info__.__version__
AttributeError: 'version_info' object has no attribute '__version__'

依赖要求

Carla Simulator指定的依赖版本:

Pillow>=3.1.2
numpy>=1.14.5
protobuf>=3.6.0
pygame>=1.9.4
matplotlib>=2.2.2
future>=0.16.0
scipy>=0.17.0

解决步骤

这个错误是pyparsing版本与Python3.6不兼容导致的,高版本pyparsing已停止支持Python3.6,需安装适配版本:

  • 卸载当前pyparsing:
    pip uninstall -y pyparsing
    
  • 安装兼容Python3.6的pyparsing版本(推荐2.4.7,适配matplotlib2.2.2的依赖要求):
    pip install pyparsing==2.4.7
    
  • 验证安装结果:
    pip show pyparsing
    
    确认输出的版本为2.4.7即可。
  • 重新运行module_7.py。

补充说明

由于你使用的是Python3.6,部分新发布的库已不再支持该版本,后续安装依赖时需优先选择标注支持Python3.6的版本,避免出现类似兼容性问题。

内容的提问来源于stack exchange,提问作者Hrishikesh k

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 02:50:16