OS: Ventura 13.2
PsychoPy version: 2022.2.4
Install method: stand-alone download
Purpose: Running a mouse-tracker in PsychoPy
I am attempting to import PyAutoGui into PsychoPy, so that I can track mouse movements (the end goal is building a time intensity curve).
PyAutoGui is installed successfully with the computer’s standard Python 3 install (version 3.9.6). However, PsychoPy is giving the following error when I try and import PyAutoGui:
File
“/Users/terryacree/Desktop/Flavometer/timeintensity_run_lastrun.py”,
line 101, in
import pyautogui, sys
ModuleNotFoundError: No module named ‘pyautogui’
Experiment ended with exit code 1 [pid:68944]
I have tried searching for previous answers on this, but all answers seemed to focus on making sure PyAutoGui was installed to Python, which I have confirmed.
PsychoPy uses its own Python virtual environment if you’re running from the app, so installing packages to your system Python won’t do anything. There are ways to install additional packages into the app’s virtual environment, see here: Adding new python module to standalone psychopy
Thank you for the solution! I am pretty new to PsychoPy, so when I tried to follow the instructions to add a new python module I was a little bit confused.
I downloaded the file “PyAutoGUI-0.9.53.tar.gz” from the PyPI website. I then opened the file using the command “tar -zxvf pyautogui-0.9.53.tar.gz”. I then found copied and pasted the file path of the PyAutoGUI folder and pasted it in the open text box for “Path” under the PsycoPy “Preferences”. Did I take the correct steps to add the module?
Apologies for the confusion on my end. Thank you!
The path thing seems to be inconsistent as to whether it works or not. The most reliable solution would be to copy the whole PyAutoGUI folder into the library folder for PsychoPy’s virtual environment. Since you’re on Mac, you can find it by right-clicking the app icon, going to “show package contents”, then Contents/resources/lib/python3.8, and then just paste the whole folder there. It should then be accessible to the PsychoPy virtual environment.