Pyinstaller does not include libsndfile












0















I created an executable with this code and pyinstaller:



import soundfile

print("Hello!")
input("Ok")


But it doesn't run correctly. I get the following error:



Traceback (most recent call last):
File "libsite-packagessoundfile.py", line 142, in <module>
OSError: sndfile library not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "prueba.py", line 1, in <module>
import soundfile
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIvenv1libsite-packagesPyInstallerloaderpyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "libsite-packagessoundfile.py", line 163, in <module>
OSError: cannot load library 'C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIdistprueba_soundfile_datalibsndfile32bit.dll': error 0x7e
[9780] Failed to execute script prueba


Since I used the standard pyinstaller command pyinstaller prueba.py I was able to make the executable work by copying the original _soundfile_data folder in the dist folder. However, I would like to use the --onefile option to make my program easier to distribute. How can I make pyinstaller work as it is supposed to?










share|improve this question



























    0















    I created an executable with this code and pyinstaller:



    import soundfile

    print("Hello!")
    input("Ok")


    But it doesn't run correctly. I get the following error:



    Traceback (most recent call last):
    File "libsite-packagessoundfile.py", line 142, in <module>
    OSError: sndfile library not found

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "prueba.py", line 1, in <module>
    import soundfile
    File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    File "C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIvenv1libsite-packagesPyInstallerloaderpyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
    File "libsite-packagessoundfile.py", line 163, in <module>
    OSError: cannot load library 'C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIdistprueba_soundfile_datalibsndfile32bit.dll': error 0x7e
    [9780] Failed to execute script prueba


    Since I used the standard pyinstaller command pyinstaller prueba.py I was able to make the executable work by copying the original _soundfile_data folder in the dist folder. However, I would like to use the --onefile option to make my program easier to distribute. How can I make pyinstaller work as it is supposed to?










    share|improve this question

























      0












      0








      0








      I created an executable with this code and pyinstaller:



      import soundfile

      print("Hello!")
      input("Ok")


      But it doesn't run correctly. I get the following error:



      Traceback (most recent call last):
      File "libsite-packagessoundfile.py", line 142, in <module>
      OSError: sndfile library not found

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "prueba.py", line 1, in <module>
      import soundfile
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIvenv1libsite-packagesPyInstallerloaderpyimod03_importers.py", line 627, in exec_module
      exec(bytecode, module.__dict__)
      File "libsite-packagessoundfile.py", line 163, in <module>
      OSError: cannot load library 'C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIdistprueba_soundfile_datalibsndfile32bit.dll': error 0x7e
      [9780] Failed to execute script prueba


      Since I used the standard pyinstaller command pyinstaller prueba.py I was able to make the executable work by copying the original _soundfile_data folder in the dist folder. However, I would like to use the --onefile option to make my program easier to distribute. How can I make pyinstaller work as it is supposed to?










      share|improve this question














      I created an executable with this code and pyinstaller:



      import soundfile

      print("Hello!")
      input("Ok")


      But it doesn't run correctly. I get the following error:



      Traceback (most recent call last):
      File "libsite-packagessoundfile.py", line 142, in <module>
      OSError: sndfile library not found

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "prueba.py", line 1, in <module>
      import soundfile
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIvenv1libsite-packagesPyInstallerloaderpyimod03_importers.py", line 627, in exec_module
      exec(bytecode, module.__dict__)
      File "libsite-packagessoundfile.py", line 163, in <module>
      OSError: cannot load library 'C:UsersDianaCarolinaGoogle DriveHumboldtDTF_GUIdistprueba_soundfile_datalibsndfile32bit.dll': error 0x7e
      [9780] Failed to execute script prueba


      Since I used the standard pyinstaller command pyinstaller prueba.py I was able to make the executable work by copying the original _soundfile_data folder in the dist folder. However, I would like to use the --onefile option to make my program easier to distribute. How can I make pyinstaller work as it is supposed to?







      python-3.x pyinstaller libsndfile






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 2:43









      dduquedduque

      338




      338
























          2 Answers
          2






          active

          oldest

          votes


















          0














          add as external hook like this



          pyinstaller <your parameters> --hidden-import='package.module'





          share|improve this answer
























          • What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

            – dduque
            Nov 30 '18 at 15:52











          • e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

            – MohitGhodasara
            Dec 3 '18 at 5:48



















          0














          You can use the --add-binary option in cases like this. For example:



          --add-binary /path/to/_soundfile_data/libsndfile.dylib:_soundfile_data



          In my case I find the (active) conda environment pysndfile is installed into and get libsndfile out of that: --add-binary $(dirname $(which python))/../lib/python3.7/site-packages/_soundfile_data/libsndfile.dylib:_soundfile_data






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440062%2fpyinstaller-does-not-include-libsndfile%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            add as external hook like this



            pyinstaller <your parameters> --hidden-import='package.module'





            share|improve this answer
























            • What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

              – dduque
              Nov 30 '18 at 15:52











            • e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

              – MohitGhodasara
              Dec 3 '18 at 5:48
















            0














            add as external hook like this



            pyinstaller <your parameters> --hidden-import='package.module'





            share|improve this answer
























            • What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

              – dduque
              Nov 30 '18 at 15:52











            • e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

              – MohitGhodasara
              Dec 3 '18 at 5:48














            0












            0








            0







            add as external hook like this



            pyinstaller <your parameters> --hidden-import='package.module'





            share|improve this answer













            add as external hook like this



            pyinstaller <your parameters> --hidden-import='package.module'






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 30 '18 at 11:53









            MohitGhodasaraMohitGhodasara

            17415




            17415













            • What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

              – dduque
              Nov 30 '18 at 15:52











            • e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

              – MohitGhodasara
              Dec 3 '18 at 5:48



















            • What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

              – dduque
              Nov 30 '18 at 15:52











            • e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

              – MohitGhodasara
              Dec 3 '18 at 5:48

















            What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

            – dduque
            Nov 30 '18 at 15:52





            What is package.module? I already tried that putting the path to the _soundfile_data and it didn't work, it needs to copy all the folder in the dist folder for it to work and it can't be done like that. That folder is already in the site-packages folder by the way

            – dduque
            Nov 30 '18 at 15:52













            e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

            – MohitGhodasara
            Dec 3 '18 at 5:48





            e.g : from PIL import ImageTk here PIL is package and imageTk is module so hook like this --hidden-import='PIL.ImageTk'

            – MohitGhodasara
            Dec 3 '18 at 5:48













            0














            You can use the --add-binary option in cases like this. For example:



            --add-binary /path/to/_soundfile_data/libsndfile.dylib:_soundfile_data



            In my case I find the (active) conda environment pysndfile is installed into and get libsndfile out of that: --add-binary $(dirname $(which python))/../lib/python3.7/site-packages/_soundfile_data/libsndfile.dylib:_soundfile_data






            share|improve this answer




























              0














              You can use the --add-binary option in cases like this. For example:



              --add-binary /path/to/_soundfile_data/libsndfile.dylib:_soundfile_data



              In my case I find the (active) conda environment pysndfile is installed into and get libsndfile out of that: --add-binary $(dirname $(which python))/../lib/python3.7/site-packages/_soundfile_data/libsndfile.dylib:_soundfile_data






              share|improve this answer


























                0












                0








                0







                You can use the --add-binary option in cases like this. For example:



                --add-binary /path/to/_soundfile_data/libsndfile.dylib:_soundfile_data



                In my case I find the (active) conda environment pysndfile is installed into and get libsndfile out of that: --add-binary $(dirname $(which python))/../lib/python3.7/site-packages/_soundfile_data/libsndfile.dylib:_soundfile_data






                share|improve this answer













                You can use the --add-binary option in cases like this. For example:



                --add-binary /path/to/_soundfile_data/libsndfile.dylib:_soundfile_data



                In my case I find the (active) conda environment pysndfile is installed into and get libsndfile out of that: --add-binary $(dirname $(which python))/../lib/python3.7/site-packages/_soundfile_data/libsndfile.dylib:_soundfile_data







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 17 at 19:50









                Victor ShepardsonVictor Shepardson

                11




                11






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440062%2fpyinstaller-does-not-include-libsndfile%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini