How to run external "cardioception" module from Standalone PsychoPy app

OS Win10
PsychoPy version 2022.2.5 - but have changed version to 2021.2.3 in Experiment Settings due to compatibility issues with the desired external module
**Standard Standalone? y
What are you trying to achieve?:
I would like to insert the following code chunk into a routine in the builder so that I can run some trials from the Heart Rate Discrimination task in my experiment. The Heart Rate Discrimination task is available using the external “cardioception” module

from cardioception.HRD.parameters import getParameters
from cardioception.HRD import task

# Set global task parameters
parameters = getParameters(
    participant='Subject_01', session='Test', serialPort=None,
    setup='test', nTrials=10, screenNb=0)

# Run task, confidenceRating=True, runTutorial=True)


I got this code from the cardioception module GitHub page and it should run 10 trials of the Heart Rate Discrimination task.

What did you try to make it work?:
I used pip install within a virtual environment I created in Anaconda to install the “cardioception” module and all its dependencies. When I run the above code within the environment it works perfectly. But when I tried to do it from within the PsychoPy builder it couldn’t find the module, so I updated the preferences in PsychoPy to add the site-packages folder created in the virtual environment to path. This allowed PsychoPy to find the cardioception module, however, it then started to give the following error message:

## Running: C:\Users\Carmen Daoust\Desktop\Experiment_Master\PsychoPy2_exp\ ##
3183.1054     INFO     Loaded monitor calibration from ['2023_01_20 18:47']
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Traceback (most recent call last):
Hello from the pygame community.
2.3362     WARNING     We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'pyo', 'pygame'] (in that order).
4.3786     WARNING     User requested fullscreen with size [1024  768], but screen is actually [1920, 1080]. Using actual size
  File "C:\Users\Carmen Daoust\Desktop\Experiment_Master\PsychoPy2_exp\", line 203, in <module>
    from cardioception.HRD.parameters import getParameters
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\cardioception\", line 4, in <module>
    from .HBC import *
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\cardioception\HBC\", line 1, in <module>
    from .parameters import *
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\cardioception\HBC\", line 11, in <module>
    from systole import serialSim
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\systole\", line 3, in <module>
    from .correction import *
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\systole\", line 8, in <module>
    from systole.detection import rr_artefacts
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\systole\", line 7, in <module>
    from ecgdetectors import Detectors
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\", line 11, in <module>
    import pywt
  File "C:\Anaconda\envs\experiment_env_3716\Lib\site-packages\pywt\", line 15, in <module>
    from ._extensions._pywt import *
ModuleNotFoundError: No module named 'pywt._extensions._pywt'

I thought adding the pywt folder specifically to path in preferences might help, but it didn’t make any difference so I removed it. I have also tried adding a .pth file to Program files\PsychoPy\Lib\site-packages with C:\Anaconda\envs\experiment_env_3716\Lib\site-packages as the path, but this didn’t seem to work either.

This is my first experience trying to build an experiment or use Python, so I’m not sure if I’m making a really obvious mistake - but any advice would be much appreciated!

Update: I managed to fix the issue by opening a Powershell within the virtual environment I loaded “cardioception” into. I then opened the builder from within that environment and now all the modules can be found properly.