Bonjour à tous,

J’essaie de créer un exécutable avec py2exe et python 3.4 sous Windows 10.

Ci-dessous, une version simplifiée de mon programme, mais qui ne fait que lire les fichiers audio dans un dossier et les écrire dans un autre dossier.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import soundfile as snd
baseDir = r"C:\pAcapela"
inputDir = os.path.join(baseDir, "inputAudio")
outputDir = os.path.join(baseDir, "outputAudio")
os.makedirs(outputDir, exist_ok=True)
# test
for path, dirs, files in os.walk(inputDir):
    for sentence in files:
        filename = os.path.join(path, sentence)
        print(filename)
        y, sr = snd.read(filename)
        # traitements ...
 
 
        # sauvergarde audio
        filesp = os.path.join(outputDir, sentence)
        snd.write(filesp, y, sr)
Le code s’execute sans problème (en supposant que le répertoire C:\pAcapela\ inputAudio existe et contient des .wav)

J’ai crée un setup.py basique:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
from distutils.core import setup
import py2exe
 
packages = []
setup(
    console=['testEasy.py'],
    options={
        "py2exe": {
            "packages": packages
        }
    }
)
La commande : python setup.py py2exe me donne le log suivant :

running py2exe
Error: Namespace packages not yet supported: Skipping package 'win32com.gen_py'

12 missing Modules
------------------
? backports.ssl_match_hostname imported from setuptools.ssl_support
? distutils._msvccompiler imported from setuptools.monkey
? mklfft imported from numpy.fft
? pkg_resources.extern.appdirs imported from pkg_resources
? pkg_resources.extern.packaging imported from pkg_resources, setuptools.command.egg_info, setuptools.dist
? pkg_resources.extern.six imported from pkg_resources
? readline imported from cmd, code, pdb
? sets imported from nose.util, numpy.distutils.command.build_ext, numpy.distutils.fcompiler, numpy.distutils.misc_util
? setuptools.extern.six imported from setuptools, setuptools.command.bdist_egg, setuptools.command.develop, setuptools.command.easy_install, setuptools.command.egg_info, setuptools.command.sdist, setuptools.command.setopt, setuptools.depends, setuptools.dist, setuptools.extension, setuptools.monkey, setuptools.package_index, setuptools.sandbox, setuptools.ssl_support, setuptools.unicode_utils
? setuptools_svn imported from setuptools.command.egg_info
? urllib.splittag imported from setuptools.py26compat
? wincertstore imported from setuptools.ssl_support

2 submodules that appear to be missing, but could also be global names in the parent package
---------------------------------------------------------------------------------------------
? numpy.core.intp imported from numpy.linalg.linalg
? numpy.core.object_ imported from numpy.linalg.linalg
Building 'dist\testEasy.exe'.
Building shared code archive 'dist\library.zip'.
Copy c:\users\laure\anaconda3\envs\py34\python34.dll to dist
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\win32\_win32sysloader.pyd to dist\_win32sysloader.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\pyexpat.pyd to dist\pyexpat.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_ssl.pyd to dist\_ssl.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\_cffi_backend.pyd to dist\_cffi_backend.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\select.pyd to dist\select.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\win32\win32evtlog.pyd to dist\win32evtlog.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\numpy\core\umath.pyd to dist\numpy.core.umath.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_multiprocessing.pyd to dist\_multiprocessing.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\unicodedata.pyd to dist\unicodedata.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\numpy\linalg\lapack_lite.pyd to dist\numpy.linalg.lapack_lite.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_lzma.pyd to dist\_lzma.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\win32\win32pdh.pyd to dist\win32pdh.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\numpy\linalg\_umath_linalg.pyd to dist\numpy.linalg._umath_linalg.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\numpy\core\multiarray.pyd to dist\numpy.core.multiarray.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_socket.pyd to dist\_socket.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\Pythonwin\win32ui.pyd to dist\win32ui.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_ctypes.pyd to dist\_ctypes.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_hashlib.pyd to dist\_hashlib.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\numpy\fft\fftpack_lite.pyd to dist\numpy.fft.fftpack_lite.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\numpy\random\mtrand.pyd to dist\numpy.random.mtrand.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\DLLs\_bz2.pyd to dist\_bz2.pyd
Copy C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\win32\win32api.pyd to dist\win32api.pyd
Copy DLL C:\Users\laure\Anaconda3\envs\py34\Library\bin\mkl_intel_thread.dll to dist\
Copy DLL C:\Users\laure\Anaconda3\envs\py34\MSVCR100.dll to dist\
Copy ExtensionDLL C:\Users\laure\Anaconda3\envs\py34\pywintypes34.dll to dist\
Copy ExtensionDLL C:\Users\laure\Anaconda3\envs\py34\pythoncom34.dll to dist\
Ça me produit un executable dans le répertoire “dist”.
Bon. Sauf que si j’exécute celui-ci, j’obtiens les erreurs suivantes :

Traceback (most recent call last):
File "C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\soundfile.py", line 142, in <module>
raise OSError('sndfile library not found')
OSError: sndfile library not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "testEasy.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Users\laure\Anaconda3\envs\py34\lib\site-packages\soundfile.py", line 163, in <module>
_path, '_soundfile_data', _libname))
OSError: cannot load library 'C:\Users\laure\PycharmProjects\debruiteAcapela\dist\_soundfile_data\libsndfile64bit.dll': error 0x7e

Bon, je suppose qu’il y a un problème avec libsndfile. Pourtant, il y a bien un fichier libsndfile64bit.dll quelque part dans C:\Users\laure\Anaconda3\envs\py34\lib\…

Est-ce que l’un d’entre vous pourrait m’aider à résoudre mon problème?

Merci d’avance.