How to use PsychoPy within a virtual environment?

I’m on Mac OS with an M2 chip, version 13.0 and I am making a python script to run my experiment in PsychoPy. I have noticed that when I open my script in VS Code, all of my imports work, but when I try to use this script in PsychoPy, my import of uldaq no longer works (I get a ModuleNotFoundError: No module named ‘uldaq’). I think the problem might have something to do with not being in my virtual environment, since I am within a virtual environment that I made in VS Code, but I do not think that I am in it in PsychoPy. So, my question is how can I either open PsychoPy in my Mac terminal within my virtual environment or open my virtual environment within PsychoPy? Or if you think that this is not the issue, what else could be causing this?

If you’re using the PsychoPy app, it basically creates its own virtual environment. You can add libraries to that environment with a few extra steps, see here: Adding new python module to standalone psychopy

In the latest version you can also install packages via the dialog in Tools → Plugins / packages manager…

Thank you for your replies. I pip installed uldaq (the package that I need to use for my experiment) and am now getting a different error from the original module not found error, which now reads:

OSError: dlopen(/usr/local/lib/libuldaq.dylib, 0x0006): tried: ‘/usr/local/lib/libuldaq.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libuldaq.dylib’ (no such file), ‘/usr/local/lib/libuldaq.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)), ‘/usr/local/lib/libuldaq.1.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libuldaq.1.dylib’ (no such file), ‘/usr/local/lib/libuldaq.1.dylib’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’))

Could you provide some more information about why I might be getting this error while using the PsychoPy app on my M2 Mac, but not while using VS Code outside of PsychoPy?

Are you installing via VS Code on a different computer? From the sounds of that error message there’s something incompatible between that module and your Mac