Python exe, созданный с использованием cx_Freeze, выдает ошибку

Я создал файл.exe для одного из моих сценариев прогнозирования, используя cx_Freeze, ниже файла setup.py, используемого для создания файла.exe

from cx_Freeze import setup, Executable
import os

import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')



options = {
    'build_exe': {
        'include_files':[
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
         ],
    },
}

additional_mods = ['numpy.core._methods', 'numpy.lib.format']


setup(name = "Prediction" ,
      version = "0.1" ,
      description = "" ,
      options = {'build_exe': {'includes': additional_mods}},
      executables = [Executable("Prediction.py")])

Но когда я попытался выполнить его, я получил ошибку ниже

ImportError: не может импортировать имя "shorttest_path"

.exe файл, созданный с помощью другого метода pyinstaller, работал нормально, но я не уверен, почему.exe, созданный с помощью cx_Freeze, не работает.

Я пытался проверить эту ошибку, но не смог найти решение, может кто-нибудь помочь мне в этом.

Как и просили поделиться сценарием прогнозирования

import os
import pandas as pd       
from bs4 import BeautifulSoup
import re
from nltk.corpus import stopwords # Import the stop word list
from nltk.tokenize import word_tokenize
import pickle
from nltk.stem import WordNetLemmatizer

# Read the test data
test = pd.read_csv("Future.csv",encoding='cp1252')

##wordnet_lemmatizer
wordnet_lemmatizer = WordNetLemmatizer()

def Description_to_words(raw_Description):
    Description_text = BeautifulSoup(raw_Description).get_text() 
    letters_only = re.sub("[^a-zA-Z]", " ", Description_text)
    words = word_tokenize(letters_only.lower())    
    stops = set(stopwords.words("english")) 
    meaningful_words = [w for w in words if not w in stops]
    return( " ".join(wordnet_lemmatizer.lemmatize(w) for w in meaningful_words))

num_Descriptions = len(test["message"])
clean_test_Descriptions = [] 

print("Cleaning and parsing the test mail message...\n")
for i in range(0,num_Descriptions):
    if( (i+1) % 1000 == 0 ):
        print("Description %d of %d\n" % (i+1, num_Descriptions))
    clean_Description = Description_to_words( test["message"][i] )
    clean_test_Descriptions.append( clean_Description )



vect=pickle.load(open("vector.pickel","rb"))
test_data_features = vect.transform(clean_test_Descriptions)

test_data_features = test_data_features.toarray()

# Use the 
svc=pickle.load(open("classifier-svc.pickel","rb"))
resultsvc= svc.predict(test_data_features)
resultsvcP= svc.predict_proba(test_data_features)

resultsvcPD = pd.DataFrame(resultsvcP)
max_per_row = resultsvcPD.max(axis=1)

output = pd.DataFrame( data={"label":test["label"], "PredictedLabel":resultsvc, "message":test["message"],"MaxProbability":max_per_row} )

output.to_csv( "Result.csv")

0 ответов

Другие вопросы по тегам