Hey, I’m new to Python and Psychopy but not really to programming. I’ve tried running the following:
print("foo")
from psychopy import visual, core, gui, event
print("bar")
Both from the command line and inside the Spyder IDE, I get the following error:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from psychopy import visual, core, gui, event
ModuleNotFoundError: No module named 'psychopy'
System specs: macOS High Sierra v.10.13.4, Macbook Air
Python version: Python 3.7.1 (python -V)
I’ve installed the following dependencies: wxPython, pyo, and the ones in the following code:
All from this resource. It seemed to run without a hitch (aside from some that didn’t like Spyder, but I ran it on the command line as well as Spyder, so that shouldn’t be a problem).
Hi! I am having the same problem. I’m trying to import psychopy on spyder (not for the actual experiment but just to fiddle around with a few things). I keep pip installing it in the python console on spyder, however, whenever I try to import it in a script, it says:
ModuleNotFoundError: No module named ‘psychopy’
Btw. I also have psychopy downloaded normally to run the actual experiment etc. Does anyone know how to fix this?
I would have thought it is, however, how would one check this? And unfortunately, it doesn’t happen when installing & importing modules other than psychopy. Is pip installing it in the python console & then importing it in a script a legitimate way to run psychopy in Spyder?
EDIT: I have tried creating a environment in anaconda using conda create & activated it, however, when I try to install psychopy in that environment, I get the following error.
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-install-kd5wnd94/greenlet/setup.py'"'"'; __file__='"'"'/private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-install-kd5wnd94/greenlet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-record-jdgoi765/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/greenlet
cwd: /private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-install-kd5wnd94/greenlet/
Complete output (9 lines):
running install
running build
running build_ext
building 'greenlet' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.8
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c greenlet.c -o build/temp.macosx-10.9-x86_64-3.8/greenlet.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-install-kd5wnd94/greenlet/setup.py'"'"'; __file__='"'"'/private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-install-kd5wnd94/greenlet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/xw/lplw3cms2v78w_f7l8kbjv3m0000gn/T/pip-record-jdgoi765/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/greenlet Check the logs for full command output.
I think you might need to install or update Apple’s command line tools required to build and install some packages. I used to think this required the massive Xcode install, but apparently not, e.g. see: