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

Anaconda环境Spyder启动异常解决咨询:从PyQt模块缺失到包冲突引发文件找不到错误

Fixing Spyder Startup Error on MacOS M1 Monterey

Your Environment

  • Python 3.9
  • Anaconda 3
  • MacOS M1 Monterey 12.1

Problem Walkthrough

  1. First, launching Spyder threw: ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'
  2. Trying pip install PyQt5.QtWebKitWidgets resulted in a metadata-generation-failed error
  3. Running conda install -c anaconda pyqt worked fine, but conda install -c conda-forge pyqtwebengine caused massive package conflicts
  4. Now, starting Spyder gives this new error:

/Users/myname/opt/anaconda3/bin/pythonw: line 3: /Users/myname/opt/anaconda3/python.app/Contents/MacOS/python: No such file or directory

Step-by-Step Solutions

1. Fix the Python.app Path Issue

This error means the pythonw script is pointing to a non-existent Python executable—likely broken by the earlier package conflict. Here's how to fix it:

  • First, check if the path actually exists:
    ls /Users/myname/opt/anaconda3/python.app/Contents/MacOS/
    
  • If there's no python file there, back up the current pythonw script first:
    cp /Users/myname/opt/anaconda3/bin/pythonw /Users/myname/opt/anaconda3/bin/pythonw.bak
    
  • Find your actual Anaconda Python executable path:
    which python
    
    On M1 Macs, this is usually /Users/myname/opt/anaconda3/bin/python
  • Edit the pythonw script to use the correct path:
    nano /Users/myname/opt/anaconda3/bin/pythonw
    
    Replace the third line's path with the one you found, then save and exit (Ctrl+O, Enter, Ctrl+X in nano).

Package conflicts often happen when mixing packages from defaults and conda-forge channels. For M1 Macs, using conda-forge exclusively avoids most architecture-related issues:

  • Create a new environment for Spyder:
    conda create -n spyder-env python=3.9 -c conda-forge
    conda activate spyder-env
    
  • Install Spyder and its required PyQt dependencies (conda-forge handles dependencies automatically):
    conda install spyder pyqt pyqtwebengine -c conda-forge
    
  • Launch Spyder to test:
    spyder
    

3. Reset Spyder Configuration (If Needed)

Corrupted config files can also cause startup problems. Reset them with:

spyder --reset

Then try launching Spyder again.

Additional Tips

  • Make sure you're using the native arm64 version of Anaconda (not the x86_64 version running via Rosetta). Check with conda info—look for platform : osx-arm64 in the output.
  • Avoid mixing pip and conda installs in the same environment, especially for complex libraries like PyQt. Conda manages dependencies more reliably for these cases.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 21:27:29