问题
I’m trying to install psychopy on Python 3 on a Mac but I get an error:
pip3 install psychopy
Collecting psychopy
Using cached PsychoPy-1.84.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File “”, line 1, in
File “/private/var/folders/39/88clnp910zlg54lrgy0d7qm40000gn/T/pip-build-ddca2hwz/psychopy/setup.py”, line 28, in
exec(vStr)
File “”, line 42, in
File “/private/var/folders/39/88clnp910zlg54lrgy0d7qm40000gn/T/pip-build-ddca2hwz/psychopy/psychopy/init.py”, line 47, in
from psychopy.tools.versionchooser import useVersion, ensureMinimal
File “/private/var/folders/39/88clnp910zlg54lrgy0d7qm40000gn/T/pip-build-ddca2hwz/psychopy/psychopy/tools/versionchooser.py”, line 19, in
from psychopy import logging, tools, web
File “/private/var/folders/39/88clnp910zlg54lrgy0d7qm40000gn/T/pip-build-ddca2hwz/psychopy/psychopy/web.py”, line 13, in
import httplib
ImportError: No module named ‘httplib’
----------------------------------------
Command “python setup.py egg_info” failed with error code 1 in /private/var/folders/39/88clnp910zlg54lrgy0d7qm40000gn/T/pip-build-ddca2hwz/psychopy/
I tried to install “httplib” but no luck there also:
pip3 install httplib
Collecting httplib
Could not find a version that satisfies the requirement httplib (from versions: )
No matching distribution found for httplib
How should I install it?
回答1:
The error in importing httplib
is caused by using Python 2 code with Python 3. httplib is a built-in library provided by Python 2.x – it cannot be installed with Pip, and has been renamed to http.client
in Python 3.
After checking the installation instructions, it appears that Python 3 is not supported as of version 1.85.4:
Dependencies
You need a copy of Python 2.7.x from here, wxPython and probably pyo (or use an alternative audio library listed below).
You will need to install and use Python 2.7 instead, unfortunately, as Python 3 will not work, and you'll likely experience many Python 3 bugs even if you did fix the direct issue with httplib
yourself.
回答2:
Oren has duplicated the question on the PsychoPy forum and I answered it there: https://discourse.psychopy.org/t/cant-install-psychopy-in-python3-mac/3573/5
The repository version of PsychoPy is now compatible but, as Jonas says, it was a major refactor (needed an upgrade to wx4 from wx3 as well) and is likely to have bugs. Not recommended unless you know what you're doing.
来源:https://stackoverflow.com/questions/47846734/cant-install-psychopy-module-on-python-3-mac