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
- First, launching Spyder threw:
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets' - Trying
pip install PyQt5.QtWebKitWidgetsresulted in ametadata-generation-failederror - Running
conda install -c anaconda pyqtworked fine, butconda install -c conda-forge pyqtwebenginecaused massive package conflicts - 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
pythonfile there, back up the currentpythonwscript first:cp /Users/myname/opt/anaconda3/bin/pythonw /Users/myname/opt/anaconda3/bin/pythonw.bak - Find your actual Anaconda Python executable path:
On M1 Macs, this is usuallywhich python/Users/myname/opt/anaconda3/bin/python - Edit the
pythonwscript to use the correct path:
Replace the third line's path with the one you found, then save and exit (Ctrl+O, Enter, Ctrl+X in nano).nano /Users/myname/opt/anaconda3/bin/pythonw
2. Create a Clean Conda Environment (Recommended)
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 forplatform : osx-arm64in the output. - Avoid mixing
pipandcondainstalls in the same environment, especially for complex libraries like PyQt. Conda manages dependencies more reliably for these cases.
内容的提问来源于stack exchange,提问作者Dharmik
相关产品推荐
相关产品推荐

