Anaconda启动Spyder报错求助:PyQt相关冲突致无法打开
Hey there, I’ve dealt with this exact Qt library conflict issue before when working with PyQt5 and Spyder in Anaconda—let’s break down what’s happening and how to fix it:
First, let’s recap the error you’re seeing for clarity:
objc[6276]: Class RunLoopModeTracker is implemented in both /Users/dwaynesmith/opt/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (0x11a64e110) and /Users/dwaynesmith/opt/anaconda3/lib/libQt5Core.5.9.7.dylib (0x125aeba80). One of the two will be used. Which one is undefined.
Traceback (most recent call last):
File "/Users/dwaynesmith/opt/anaconda3/bin/spyder", line 11, in
sys.exit(main())
File "/Users/dwaynesmith/opt/anaconda3/lib/python3.7/site-packages/spyder/app/start.py", line 201, in main
from spyder.app import mainwindow
File "/Users/dwaynesmith/opt/anaconda3/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 83, in
from qtpy import QtWebEngineWidgets # analysis:ignore
File "/Users/dwaynesmith/opt/anaconda3/lib/python3.7/site-packages/qtpy/QtWebEngineWidgets.py", line 22, in
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ValueError: PyCapsule_GetPointer called with incorrect name
This is caused by conflicting Qt library versions in your Anaconda environment—PyQt5 is bringing its own QtCore, but there’s another QtCore library in your Anaconda lib folder that’s conflicting with it. Here are the fixes that worked for me:
1. Reinstall Spyder and PyQt5 with Conda (Avoid Mixing Pip!)
Mixing pip and conda installs is a common cause of library conflicts. Let’s clean up and reinstall using only conda:
- First, uninstall the conflicting packages:
conda uninstall spyder pyqt5 --force - Then reinstall compatible versions together:
conda install spyder pyqt5
Try launching Spyder after this—this often resolves minor version mismatches.
2. Create a Fresh Anaconda Environment (Most Reliable Fix)
If the first method doesn’t work, isolating Spyder and PyQt5 in a new environment eliminates any existing conflicts:
- Create a new environment with Python 3.7 (matching your current version), Spyder, and PyQt5:
conda create -n spyder_pyqt_env python=3.7 spyder pyqt5 - Activate the environment:
conda activate spyder_pyqt_env - Launch Spyder from this environment:
spyder
This is the most foolproof way because the new environment has no leftover conflicting libraries.
3. Adjust Library Load Order on macOS
The error shows two QtCore libraries are being detected. We can make sure Anaconda’s PyQt5 QtCore is loaded first:
- Temporary fix (for the current terminal session):
export DYLD_LIBRARY_PATH=/Users/dwaynesmith/opt/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib:$DYLD_LIBRARY_PATH spyder - Permanent fix (add to your shell config file):
Open~/.zshrc(or~/.bash_profileif you use bash) and add this line:
Save the file, then runexport DYLD_LIBRARY_PATH=/Users/dwaynesmith/opt/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib:$DYLD_LIBRARY_PATHsource ~/.zshrc(orsource ~/.bash_profile) to apply changes, then launch Spyder.
4. Downgrade PyQt5 to Match Anaconda’s Qt Version
Your error mentions libQt5Core.5.9.7.dylib—let’s install a PyQt5 version that matches this Qt 5.9.7:
conda install pyqt5=5.9 spyder
This ensures PyQt5 uses the existing QtCore library in your Anaconda environment instead of bringing its own conflicting version.
内容的提问来源于stack exchange,提问作者DWSmithCSS




