2017-04-24 7 views
1

Ich habe eine cx_freexe .exe aus einer Reihe von Skripten, die im ursprünglichen Build-Ordner funktioniert. Allerdings, wenn ich es zu unserer Analyse Computer mit ein bisschen mehr Muskeln bewegen, bekomme ich folgende Fehlermeldung:Cx_freeze .exe funktioniert nicht, wenn verschoben

C:\Program Files\Davidek\Davidek beta 1.2.0>Davidek.exe 
Traceback (most recent call last): 
    File "C:\ProgramData\Anaconda3\lib\site-packages\cx_Freeze\initscripts\__start 
up__.py", line 12, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console 
.py", line 24, in <module> 
    File "Davidek.py", line 11, in <module> 
    File "C:\Users\Max\Scilifelab\Projects\Master thesis\Davidek\Code\TICwriter.py 
", line 7, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 
122, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook.py", line 32 
, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, 
in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 1 
3, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 
8, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\type_check.py", lin 
e 11, in <module> 
    File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 
14, in <module> 
ImportError: DLL load failed: The specified module could not be found. 

C:\Program Files\Davidek\Davidek beta 1.2.0>PAUSE 
Press any key to continue . . . 

Dies ist der Code „TICwriter.py“, die das Problem zu verursachen scheint:

import matplotlib 
#Forces matplotlib to not show plot: 
matplotlib.use('Agg') 
import matplotlib.pyplot as pl  
import os 

def TICwriter(TIC, dataFile, saveDirectory): 
    """ Saves a TIC file as a .png in the specified saveDirectory under a 
     output subdirectory. 
    """ 
    #Create savename from data file name: 
    savefile = dataFile.split('/')[-1].split('.')[0] + '_TIC.png' 
    #Create ouput directory: 
    saveDirectory = os.path.join(saveDirectory, 'output/') 
    os.makedirs(os.path.dirname(saveDirectory), exist_ok=True) 
    #Plot figure: 
    Plot = pl.figure() 
    TICplot = Plot.add_subplot(111) 
    TICplot.plot([d[0] for d in TIC], [d[1] for d in TIC]) 

    #Save and close plot: 
    pl.savefig(saveDirectory + savefile) 
    pl.close(Plot) 

Es scheint mir, wie matplotlib das Problem verursacht, da der Fehler in Zeile 7 auftritt:

:

import matplotlib 

Mein Build-Skript sieht wie folgt aus

import sys 
from os import environ 
from os.path import dirname 
from cx_Freeze import setup, Executable 
import scipy 
scipy_path = dirname(scipy.__file__) 


# Set the TCL and TK library explicitly (it seems like the python 3.6 causes 
# errors otherwise): 
environ['TCL_LIBRARY'] = r'C:\ProgramData\Anaconda3\tcl\tcl8.6' 
environ['TK_LIBRARY'] = r'C:\ProgramData\Anaconda3\tcl\tk8.6' 


#Inclusion of dll files to fix tkinter import: 
include_files = [r'C:\ProgramData\Anaconda3\DLLs\tcl86t.dll', 
       r'C:\ProgramData\Anaconda3\DLLs\tk86t.dll', 
       scipy_path] 
#Inclusion of modules that need to be explicitly imported for some reason: 
packages = []#['pyteomics'] 

#Dependencies that are not implicitly detected: 
build_exe_options = {'includes': ['numpy.core._methods', 'numpy.lib.format', 'numpy.matlib'], 
        'excludes': [], 
        'include_files': include_files, 
        'packages': packages} 

# GUI applications require a different base on Windows (the default is for a 
# console application). 
base = "Console" 

#if sys.platform == 'win32': 
# base = 'Win32GUI' 

setup( name = 'Davidek beta 1.1.1', 
     version = '1.1.1', 
     options = {'build_exe': build_exe_options}, 
     executables = [Executable('Davidek.py', base=base)]) 

Es scheint mir, dass die EXE versucht, das matplotlib-Modul im ursprünglichen Ordner von dem Computer zu suchen, auf dem die ausführbare Datei erstellt wurde, obwohl Matplotlib in dem Erstellungsordner enthalten ist. Die EXE-Datei wird ordnungsgemäß ausgeführt, wenn ich sie vom ursprünglichen Computer aus starte, auch wenn ich den Build vom ursprünglichen Ordner verschiebe. Ich benutze Python 3.6 auf 64-Bit-Windows 10. Jeder Hinweis auf dieses würde sehr geschätzt werden. Lassen Sie mich wissen, wenn weitere Informationen benötigt werden.

Danke.

Antwort

1

Ich habe es geschafft, es zu beheben, also hier gehen wir für jeden mit diesem Problem in der Zukunft: Das Problem kann durch Kopieren der folgenden Dateien aus "C: \ ProgramData \ Anaconda3 \ Library \ bin" behoben werden (oder ". .. \ Anaconda3 \ Library \ bin "), um den Erstellungsordner:

  • mkl_core.dll
  • mkl_intel_thread.dll
  • mkl_def.dll
  • libiomp5md.dll
Verwandte Themen