Hi,
I installed Standalone Psychopy On a Mac computer and I use VS Code as a code editor. How can I add the standalone psychopy as a python interpreter to vs code?
Trying to add Applications/PsychoPy.app/Contents/MacOS/python did not work.
Hi,
I installed Standalone Psychopy On a Mac computer and I use VS Code as a code editor. How can I add the standalone psychopy as a python interpreter to vs code?
Trying to add Applications/PsychoPy.app/Contents/MacOS/python did not work.
The standalone isnât going to work for you for this purpose - youâll need to install the PsychoPy library and its many dependencies into an environment with a regular Python interpreter. Itâs best to create a separate environment just for that (eg with Conda), so that you donât break your everyday Python installation (and vice versa). I imagine that VSCode is like most IDEs and will allow you to simply flick between the Python interpreters in each environment.
The disadvantage of not using the standalone is that you have to manage all of the third-party dependencies yourself, and that can cause a few hiccups along the way.
Probably best to follow the instructions for the developer install of PsychoPy - that way you can use gut to control the PsychoPy version (eg to keep consistent with the standalone app that youâll likely use when running the actual experiment).
https://psychopy.org/developers/
Thereâs a workshop coming up next week for new developers I think - that would cover everything you need to know and more about getting set up.
Sign-ups for the free workshop are here on Eventbrite: Contributing to PsychoPy Workshop Tickets, Wed. & Fri., 26 & 28 April 2023 from 2-5 pm, UK Time.
Hi,
I find this a bit strange. If standalone PsychoPy is installed on my machine, with the appropriate python version and all batteries included (1.2 GB disk space), and apparently uses its own virtual environment, why canât I tap into (activate) that virtual environment from outside, e.g., from VS Code? Is it a protection issue, i.e., I should not be able to install additional software into that environment, or even worse replace parts?
I also donât understand this, and thought that copying the files out would fix it, but no dice, it would be interesting to find out why because Iâm having a lot of trouble overcoming the dependencies issue doing things the conventional way.
PsychoPy isnât using a âvirtual environmentâ. Itâs using a packaged version of Python designed to work as an application (using py2app). There is no âactivatingâ that virtual environment. If you want to run that python then you have to call the full path to that python
When I use VS Code and set it to use /Applications/PsychoPy.app/Contents/MacOS/python
as the interpreter, it works as expected.
Notably, Iâm selecting the âEnter interpreter pathâŚâ option here, as below. Are you doing something else?
Nice, thanks!
Back then, this is what I was trying as well but it did not work. I somehow solved this issue but I donât remember how. I may have installed it using anaconda instead of the installer. But I remember that when I did it using anaconda the installation was getting stuck at some point as well.
Conda has certainly had issues before with some libs (like hdf5 and wxpython) and I donât have time to battle with it.
But maybe something changed about the way that the py2app packages the python executable in the bundle that means it now âjust worksâ. I mean thatâs my experience, but not working for @AlexHolcombe
My feeling is that this could be due to your MacOS version. What is your MacOS version? Maybe Apple has some security precaution to prevent malicious users from running Python code from an app.
If it doesnât work using Jonâs method, and conda gets stuck using the anaconda install method (which it did for me) you could use conda just as a virtual environment manager, create a conda environment (note that on a Mac you need python 3.8) with
conda create python=3.8 -n psychopy
activate the environment using
conda activate psychopy
and then use pip to install psychopy into that environment.
pip install psychopy
That worked for me, and the environment can be used from VS Code,
That possibility now seems to have been ruled out by my attempts documented here: Installing Psychopy to run with an external editor - #4 by AlexHolcombe
Yes, thatâs what Iâm doing, but have also tried it outside VSCode, as we now discuss at the other thread Installing Psychopy to run with an external editor - #4 by AlexHolcombe