# Not locating a file - Called by an scripted module

**URL:** <https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070>\
**Category:** Development\
**Created:** [December 13, 2018, 5:12pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070 "2018-12-13T17:12:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jadam1995](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jadam1995](https://discourse.slicer.org/u/jadam1995)\
**Post date:** [December 13, 2018, 5:12pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/1 "2018-12-13T17:12:22Z")

</div>

Operating system: Windows (6.1.7601)  
Slicer version: 4.10.0  
Expected behavior: Load in python package to slicer, package is loaded, use package in scripted module to access and load an external audio data file.  
Actual behavior: Load in python package to slicer, package is loaded, script loaded module cannot locate external file.

Hello,

I am trying to implement a specific sound feedback in Slicer to play a specific audio file in response to an observed change in a node. I am attempting to use the python module _pydub_. I have imported this into slicer using the following:

import pip  
pip.main(‘install’, ‘pydub’)

The module is loaded into Slicer, but when I attempt to use this module to access an external .wav file

out\_audio = AudioSegment.from\_wav("/tmp/file.wav")

it fails to recognize the file (Windows Error 2, the file or directory does not exist. is this an issue with Slicer being able to open a file called by an external command? If anyone has an insight into why I may be getting this issue I would greatly appreciate your input.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 13, 2018, 5:33pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/2 "2018-12-13T17:33:46Z")

</div>

The `/tmp/file.wav` is not a full path on Windows. Verify the path and make sure to include drive name: `C:/tmp/file.wav`.

You can also replay sound using Qt or for more flexibility use a sound synthesizer (by using/customizing [SoundControl](https://github.com/SlicerIGT/SlicerSoundControl) extension).

---

<div class="post-metadata">

**Author:** ![jadam1995](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jadam1995](https://discourse.slicer.org/u/jadam1995)\
**Post date:** [December 13, 2018, 7:00pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/3 "2018-12-13T19:00:26Z")

</div>

The `/tmp/file.wav` was a typo, I was using the path with the full drive name:`C:/tmp/file.wav`.

In regards to customizing the SoundControl extension, I had previously tried to work with this extension but was getting an error ([Breach warning, Open Sound Control, test with Pure Data errors](https://discourse.slicer.org/t/breach-warning-open-sound-control-test-with-pure-data-errors/5045)) which i belive is related to purr-data.

Also, the use of Qt in python would require some form of C++ wrapping would it not? I know that the PyQT provides binding for Qt but I am not sure if I would be able to use this within Slicer.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 13, 2018, 9:40pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/4 "2018-12-13T21:40:38Z")

</div>

All Qt classes (with a few exceptions) are Python-wrapped and heavily used in all scripted modules in Slicer.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [December 13, 2018, 11:14pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/5 "2018-12-13T23:14:29Z")

</div>

Yes, Qt already have python-wrapping in Slicer using PythonQt. You can see in the OpenSoundControl python module [here](https://github.com/SlicerIGT/SlicerSoundControl/blob/master/OpenSoundControl/OpenSoundControl.py#L3) where the python wrapped qt package is imported.

I would suggest to keep debugging that issue with the subprocess call within the OpenSoundControl extension code. I wouldn’t be surprised if the config file path is in an incorrect format. Maybe you have quotes around the path when there shouldn’t be? I haven’t tried anything myself, but giving you some ideas to try.

---

<div class="post-metadata">

**Author:** ![jadam1995](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jadam1995](https://discourse.slicer.org/u/jadam1995)\
**Post date:** [December 14, 2018, 7:45pm UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/6 "2018-12-14T19:45:17Z")

</div>

Hi,

Thanks for the suggestions! I appreciate your support. The error I am getting is actually when I just use the built in Open Sound Control module under Modules\>IGT\>Open Sound Control. When i go under the PureData Server input section and add the PureData configuration for the OscSimpleTest and then it gives the error I discussed. I have tried several different iterations or ways of expressing the path for the OscSimpleTest.pd file and none seem to work I still get the same Error 87.

Additionally, I ran the OscSimpleTest just within Purr-Data, it is producing sound but outputting these errors:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/a/7accc2ed7f72a784262a1d62a4eb23bb5e802b92.png)

Not sure if this is contributing to the problem.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 16, 2018, 2:02am UTC](https://discourse.slicer.org/t/not-locating-a-file-called-by-an-scripted-module/5070/7 "2018-12-16T02:02:55Z")

</div>

> [@jadam1995](#):
>
> Additionally, I ran the OscSimpleTest just within Purr-Data, it is producing sound but outputting these errors

I’ve just tried this and it works well. Make sure you download full pd version (including plugins) as described in instructions: [SlicerSoundControl/README.md at master · SlicerIGT/SlicerSoundControl · GitHub](https://github.com/SlicerIGT/SlicerSoundControl/blob/master/README.md)
