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

在PyCharm/VS Code运行Python文件遇exit code 139(SIGSEGV)问题求助

问题描述

运行Python文件时触发报错:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
仅在使用pyttsx3库时出现该问题,环境信息:

  • 操作系统:macOS Monterey 12.4
  • 芯片:Apple M2
    已尝试重装Python、重建.py文件、重启设备,均无法解决。
解决方法

方法1:通过Rosetta 2兼容运行

  1. 找到「终端」应用,右键选择「显示简介」
  2. 勾选「使用Rosetta打开」,重启终端
  3. 在该终端中重新安装pyttsx3:pip uninstall pyttsx3 && pip install pyttsx3
  4. 回到PyCharm/VS Code,选择该Rosetta终端对应的Python解释器运行代码

方法2:改用Apple原生语音合成方案

pyttsx3对Apple Silicon支持不佳,可直接调用系统原生API替代,示例代码:

# 使用pyobjc调用原生语音合成
from AppKit import NSSpeechSynthesizer

def speak(text):
    speaker = NSSpeechSynthesizer.alloc().init()
    speaker.startSpeakingString_(text)

speak("测试语音合成")

或直接调用系统say命令:

import subprocess

def speak(text):
    subprocess.run(["say", text])

speak("测试语音合成")

方法3:安装适配ARM架构的pyttsx3分支

在终端执行以下命令安装适配版本:

pip install git+https://github.com/nateshmbhat/pyttsx3.git

内容的提问来源于stack exchange,提问作者Paresh Dhuri

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 19:12:03