在Windows上pip安装Psychopy的报错及运行问题求助
Hey there, let's work through these frustrating import errors you're facing in your 64-bit Anaconda Spyder 2.7 environment. These issues almost always boil down to incompatible dependency versions—since Python 2.7 is end-of-life, newer library releases don't support it anymore. Here's what's worked for me and other developers in your situation:
1. Fix pyglet-related import errors (cannot import name key/logging)
The pyglet library you have installed is likely too new for Python 2.7 and your Psychopy version. Roll back to a compatible release:
- First, activate your Anaconda environment in the command prompt:
conda activate your_spyder27_env_name - Install the last pyglet version that works with Python 2.7:
If conda throws an error, use the pip command above—it's more reliable for this specific version.pip install pyglet==1.3.2
2. Reinstall a Python 2.7-compatible Psychopy version
The latest Psychopy versions dropped support for Python 2.7 entirely. Uninstall your current installation and install the last supported release:
pip uninstall psychopy -y pip install psychopy==1.85.6
This version is specifically built to work with Python 2.7 and avoids many dependency conflicts.
3. Resolve the PUINT NameError
This error stems from mismatched numpy or pygame versions. Here's how to fix it:
- First, install a numpy version compatible with Python 2.7:
conda install numpy==1.16.6 - If the error persists, reinstall a Python 2.7-friendly pygame release:
pip install pygame==1.9.6
PUINT is a type definition that exists in these older, compatible library versions.
4. Double-check your environment setup
- Confirm Spyder is using the correct interpreter: Go to
Tools > Preferences > Python interpreterin Spyder, and make sure the path points to the Python executable in your Anaconda 2.7 environment. - Restart Spyder completely after making any dependency changes—old cached imports can stick around and cause weird issues even after fixes are applied.
内容的提问来源于stack exchange,提问作者Ravi Mevada

