.. _user_guide_troubleshooting: ================ Trouble shooting ================ 本节介绍如何解决 PyDPF-Post 中遇到的最常见问题。它还包括改进脚本的建议。 Known issues list ~~~~~~~~~~~~~~~~~ 请参阅 :ref:`Known issues page ` ,了解 DPF 各版本的已知问题列表。 Installation ~~~~~~~~~~~~ pip 安装 PyDPF 库的旧版本时,可能会出现一个错误: .. code-block:: shell-session 'python_requires' must be a string containing valid version specifiers; Invalid specifier: '>=3.7.*' 在这种情况下,使用下面的命令修改 Python 环境,以使用严格早于 ``67.0.0`` 的 ``setuptools`` 库版本: .. code:: pip uninstall -y packaging; pip uninstall -y setuptools; pip install "setuptools<67.0.0" Auto-completion ~~~~~~~~~~~~~~~ 使用 ``load_simulation()`` 方法时,自动完成功能可能无法正常工作,这取决于脚本环境。该方法旨在作为一个辅助工具,可以自动检测物理类型和分析类型。 要使自动完成功能在所有情况下都能正常工作,请使用构造函数直接实例化正确的 :ref:`Simulation ` 子类: .. code-block:: default from ansys.dpf import post static_mechanical_simulation = post.StaticMechanicalSimulation('file.rst') # 静态分析 # or transient_mechanical_simulation = post.TransientMechanicalSimulation('file.rst') # 瞬态分析 # or modal_mechanical_simulation = post.ModalMechanicalSimulation('file.rst') # 模态分析 # or harmonic_mechanical_simulation = post.HarmonicMechanicalSimulation('file.rst') # 谐波分析 Invalid UTF-8 error ~~~~~~~~~~~~~~~~~~~ 假设您正在使用此代码加载模拟结果: .. code-block:: default from ansys.dpf import post simulation = post.load_simulation('file.rst') 可能会出现此错误: .. code-block:: default [libprotobuf ERROR C:\.conan\897de8\1\protobuf\src\google\protobuf\wire_format_lite.cc:578] String field 'ansys.api.dpf.result_info.v0.ResultInfoResponse.user_name' contains invalid UTF-8 data when serializing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes. 这个错误会导致模拟无法访问。为了避免这个错误,请确保您使用的 PyDPF-Post 版本在 0.2.1 之后,PyDPF-Core 版本在 0.3.2 之后。在这种情况下,警告可能仍然会出现,但应该不会阻止访问仿真。 要读取结果文件,必须为 ``load_solution()`` 方法设置 ``physics_type`` 和 ``analysis type`` 参数: .. code-block:: default from ansys.dpf import post solution = post.load_solution('file.rst', physics_type='mechanical', analysis_type='transient')