python-3.9auto-py-to-exe

I get this error when with autopy when making a py to exe. how can I solve this?


I get this error with auto-py-to-exe, when passing a .py to executable and running the exe:

 Traceback (most recent call last):
  File "NNbacktest.py", line 29, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "yfinance\__init__.py", line 23, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "yfinance\ticker.py", line 29, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "yfinance\base.py", line 32, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "yfinance\data.py", line 18, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "frozendict\__init__.py", line 33, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\jsgas\\AppData\\Local\\Temp\\_MEI100882\\frozendict\\VERSION'
[13020] Failed to execute script 'NNbacktest' due to unhandled exception!

Im importing all theese packages: -yfinance -keras -sklearn -abc -matplotlib -pandas -numpy -tensorflow

But still getting that error.

What can I do to solve this?

edited:

I'm adding a minimal reproducible example, please use auto-py-to-exe (so I can do the same)

    from backtest import *
import numpy as np
import pandas as pd
import matplotlib.pylab as plt

from keras.models import Sequential
from keras.models import Model
from keras.layers.core import Dense, Dropout, Activation, Flatten, Permute, Reshape
from keras.layers import Input, concatenate, GaussianNoise #Merge
from keras.layers import LSTM, GRU, SimpleRNN
from keras.layers import Convolution1D, MaxPooling1D, GlobalAveragePooling1D, GlobalMaxPooling1D, RepeatVector, AveragePooling1D
from keras.callbacks import ModelCheckpoint, ReduceLROnPlateau, CSVLogger, EarlyStopping
from keras.layers import Bidirectional, TimeDistributed
from keras import regularizers
from keras.layers import BatchNormalization
from keras.layers import *
from keras.optimizers import RMSprop, Adam, SGD, Nadam
from keras.initializers import *
from keras.constraints import *
from keras import regularizers
from keras import losses

from sklearn.metrics import r2_score
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
from sklearn.metrics import matthews_corrcoef


import yfinance as yf
from datetime import datetime

import os

from abc import ABCMeta, abstractmethod
import numpy as np
import pandas as pd
import matplotlib.pylab as plt


os.system("pause")

Solution

  • the problem is frozen lib .... I added this to the program:

    from pathlib import Path
    import frozendict
    
    datas = [(Path(frozendict.__path__[0]) / 'VERSION', 'frozendict')]
    

    and add all libs in collect all of autopytoexe. collect all

    After all this, the executable works as it should (perfect).