来源: stackexchange

问:
LoadLibrary : pyinstaller :format messageW failed
Created a simple app with PYQT5 and tried to compile it to .exe file, I created on window 10 pc and it works great there, but when I tried to move the software to Windows 7 ( with no python installed) it gave me this error :

here is my main.py file :

```<code># -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog

import aboutUs
import users_settings

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1332, 933)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/images/pos_logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setLayoutDirection(QtCore.Qt.RightToLeft)
        MainWindow.setStyleSheet("background:#a1d0f4;")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 3, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 2, 3, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.settingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.settingsToolButton.sizePolicy().hasHeightForWidth())
        self.settingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.settingsToolButton.setFont(font)
        self.settingsToolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/images/images/cog-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.settingsToolButton.setIcon(icon1)
        self.settingsToolButton.setIconSize(QtCore.QSize(128, 128))
        self.settingsToolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.settingsToolButton.setObjectName("toolButton_5")
        self.verticalLayout.addWidget(self.settingsToolButton)
        self.toolButton_6 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton_6.sizePolicy().hasHeightForWidth())
        self.toolButton_6.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.toolButton_6.setFont(font)
        self.toolButton_6.setStyleSheet("background:#fe3636;color:white;")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/images/images/close-window-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_6.setIcon(icon2)
        self.toolButton_6.setIconSize(QtCore.QSize(128, 128))
        self.toolButton_6.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_6.setObjectName("toolButton_6")
        self.verticalLayout.addWidget(self.toolButton_6)
        self.gridLayout.addLayout(self.verticalLayout, 2, 0, 1, 2)
        self.toolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton.sizePolicy().hasHeightForWidth())
        self.toolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton.setFont(font)
        self.toolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(":/images/images/calculator-5-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton.setIcon(icon3)
        self.toolButton.setIconSize(QtCore.QSize(256, 256))
        self.toolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton.setObjectName("toolButton")
        self.gridLayout.addWidget(self.toolButton, 1, 3, 1, 1)
        self.toolButton_2 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton_2.sizePolicy().hasHeightForWidth())
        self.toolButton_2.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_2.setFont(font)
        self.toolButton_2.setStyleSheet("background:#0a74c4;color:white;")
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(":/images/images/store-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_2.setIcon(icon4)
        self.toolButton_2.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_2.setObjectName("toolButton_2")
        self.gridLayout.addWidget(self.toolButton_2, 1, 2, 1, 1)
        self.toolButton_3 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton_3.sizePolicy().hasHeightForWidth())
        self.toolButton_3.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_3.setFont(font)
        self.toolButton_3.setStyleSheet("background:#0a74c4;color:white;")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(":/images/images/tree-structure-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_3.setIcon(icon5)
        self.toolButton_3.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_3.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_3.setObjectName("toolButton_3")
        self.gridLayout.addWidget(self.toolButton_3, 1, 1, 1, 1)
        self.userSettingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.userSettingsToolButton.sizePolicy().hasHeightForWidth())
        self.userSettingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.userSettingsToolButton.setFont(font)
        self.userSettingsToolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(":/images/images/conference-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.userSettingsToolButton.setIcon(icon6)
        self.userSettingsToolButton.setIconSize(QtCore.QSize(256, 256))
        self.userSettingsToolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.userSettingsToolButton.setObjectName("toolButton_4")
        self.userSettingsToolButton.clicked.connect(self.open_user_settings)
        self.gridLayout.addWidget(self.userSettingsToolButton, 2, 2, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1332, 21))
        self.menubar.setObjectName("menubar")
        self.menu = QtWidgets.QMenu(self.menubar)
        self.menu.setObjectName("menu")
        self.menu_2 = QtWidgets.QMenu(self.menubar)
        self.menu_2.setObjectName("menu_2")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.action = QtWidgets.QAction(MainWindow)
        self.action.setIcon(icon5)
        self.action.setObjectName("action")
        self.action_2 = QtWidgets.QAction(MainWindow)
        self.action_2.setIcon(icon4)
        self.action_2.setObjectName("action_2")
        self.action_3 = QtWidgets.QAction(MainWindow)
        self.action_3.setIcon(icon3)
        self.action_3.setObjectName("action_3")
        self.userSettingsAction = QtWidgets.QAction(MainWindow)
        self.userSettingsAction.setIcon(icon6)
        self.userSettingsAction.setObjectName("action_4")
        self.userSettingsAction.triggered.connect(self.open_user_settings)
        self.action_6 = QtWidgets.QAction(MainWindow)
        self.action_6.setIcon(icon1)
        self.action_6.setObjectName("action_6")
        self.action_7 = QtWidgets.QAction(MainWindow)
        self.action_7.setIcon(icon2)
        self.action_7.setObjectName("action_7")
        self.aboutUs_menu = QtWidgets.QAction(MainWindow)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(":/images/images/favicon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.aboutUs_menu.setIcon(icon7)
        self.aboutUs_menu.setObjectName("action_8")
        self.aboutUs_menu.triggered.connect(self.open_about_us)
        self.action_9 = QtWidgets.QAction(MainWindow)
        self.action_9.setObjectName("action_9")
        self.action_10 = QtWidgets.QAction(MainWindow)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/images/images/phone-18-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_10.setIcon(icon8)
        self.action_10.setObjectName("action_10")
        self.menu.addAction(self.action)
        self.menu.addAction(self.action_2)
        self.menu.addAction(self.action_3)
        self.menu.addAction(self.userSettingsAction)
        self.menu.addSeparator()
        self.menu.addAction(self.action_6)
        self.menu.addAction(self.action_7)
        self.menu_2.addAction(self.aboutUs_menu)
        self.menu_2.addAction(self.action_10)
        self.menubar.addAction(self.menu.menuAction())
        self.menubar.addAction(self.menu_2.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def open_about_us(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = aboutUs.Ui_Dialog()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def open_user_settings(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = users_settings.Ui_Form()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Vision store manager - Innoventiq"))
        self.label.setText(_translate("MainWindow",
                                      "<html><head/><body><p><img src=\":/images/images/logo_small.png\"/></p></body></html>"))
        self.label_2.setText(_translate("MainWindow",
                                        "<html><head/><body><p><img src=\":/images/images/pos_logo_small.png\"/></p></body></html>"))
        self.settingsToolButton.setText(_translate("MainWindow", "إعدادت عامة "))
        self.toolButton_6.setText(_translate("MainWindow", "خروج "))
        self.toolButton.setText(_translate("MainWindow", "الحسابات"))
        self.toolButton_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.toolButton_3.setText(_translate("MainWindow", "المدخلات"))
        self.userSettingsToolButton.setText(_translate("MainWindow", "إعدادات الموظفين و المستخدمين"))
        self.menu.setTitle(_translate("MainWindow", "ذهاب إلى"))
        self.menu_2.setTitle(_translate("MainWindow", "من نحن"))
        self.action.setText(_translate("MainWindow", "المدخلات"))
        self.action_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.action_3.setText(_translate("MainWindow", "الحسابات"))
        self.userSettingsAction.setText(_translate("MainWindow", "المستخدمين"))
        self.action_6.setText(_translate("MainWindow", "إعدادت البرنامج"))
        self.action_7.setText(_translate("MainWindow", "خروج من البرنامج"))
        self.aboutUs_menu.setText(_translate("MainWindow", "عن الشركة"))
        self.action_9.setText(_translate("MainWindow", "الرخصة الحالة"))
        self.action_10.setText(_translate("MainWindow", "الإتصال بنا"))

import rsc_rc

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    myStyle = 'Fusion'
    app.setStyle(myStyle)
    # The proxy style should be based on an existing style,
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.showMaximized()
    sys.exit(app.exec_())
</code>```

and here is my main.spec:

```<code># -*- mode: python -*-

block_cipher = None

a = Analysis(['main.py'],
             pathex=['E:\\Innoventiq\\vision_manager'],
             binaries=[],
             datas=[
             ('dlls/api-ms-win-core-console-l1-1-0.dll', '.'),
('dlls/api-ms-win-core-console-l1-1-0.dll','.'),
('dlls/api-ms-win-core-console-l1-2-0.dll','.'),
('dlls/api-ms-win-crt-math-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-stdio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-locale-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-heap-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-runtime-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-string-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-stdio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-heap-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-runtime-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-convert-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-math-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-process-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-conio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-filesystem-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-string-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-environment-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-time-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-stdio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-locale-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-heap-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-runtime-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-convert-l1-1-0.dll','.'),

             ],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='main',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=False , icon='app.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='main')
</code>```

I used Pyinstaller to generate the file.

答:
There are some problems with your code, and if you fix them I think your problem would be solved:

First, you need to load your external files (like *.ico in your example) properly when you want to freeze your script as one file executable. I added the first icon you can add all your other icons like that, also you can find more about that in a related question in here.

Second I suggest you disable UPX first because sometimes it can't properly bring standard PyQt DLL files with your project.

Third, I highly recommend you to build your project on Windows 7, and because of that, you don't need to feed api-ms-win*.dll as data files.

And last but not least make sure that your build and target architecture are the same (X64 or X86) and you already installed Visual C++ Redistributable on your Win7 target.

```<code># -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog
import os
import sys
import rsc_rc
import aboutUs
import users_settings

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1332, 933)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(self.resource_path(
            "./images/images/pos_logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setLayoutDirection(QtCore.Qt.RightToLeft)
        MainWindow.setStyleSheet("background:#a1d0f4;")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 3, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 2, 3, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.settingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.settingsToolButton.sizePolicy().hasHeightForWidth())
        self.settingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.settingsToolButton.setFont(font)
        self.settingsToolButton.setStyleSheet(
            "background:#0a74c4;color:white;")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/images/images/cog-256.ico"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.settingsToolButton.setIcon(icon1)
        self.settingsToolButton.setIconSize(QtCore.QSize(128, 128))
        self.settingsToolButton.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextUnderIcon)
        self.settingsToolButton.setObjectName("toolButton_5")
        self.verticalLayout.addWidget(self.settingsToolButton)
        self.toolButton_6 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton_6.sizePolicy().hasHeightForWidth())
        self.toolButton_6.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.toolButton_6.setFont(font)
        self.toolButton_6.setStyleSheet("background:#fe3636;color:white;")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(
            ":/images/images/close-window-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_6.setIcon(icon2)
        self.toolButton_6.setIconSize(QtCore.QSize(128, 128))
        self.toolButton_6.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_6.setObjectName("toolButton_6")
        self.verticalLayout.addWidget(self.toolButton_6)
        self.gridLayout.addLayout(self.verticalLayout, 2, 0, 1, 2)
        self.toolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton.sizePolicy().hasHeightForWidth())
        self.toolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton.setFont(font)
        self.toolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(
            ":/images/images/calculator-5-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton.setIcon(icon3)
        self.toolButton.setIconSize(QtCore.QSize(256, 256))
        self.toolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton.setObjectName("toolButton")
        self.gridLayout.addWidget(self.toolButton, 1, 3, 1, 1)
        self.toolButton_2 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton_2.sizePolicy().hasHeightForWidth())
        self.toolButton_2.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_2.setFont(font)
        self.toolButton_2.setStyleSheet("background:#0a74c4;color:white;")
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(":/images/images/store-256.ico"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_2.setIcon(icon4)
        self.toolButton_2.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_2.setObjectName("toolButton_2")
        self.gridLayout.addWidget(self.toolButton_2, 1, 2, 1, 1)
        self.toolButton_3 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton_3.sizePolicy().hasHeightForWidth())
        self.toolButton_3.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_3.setFont(font)
        self.toolButton_3.setStyleSheet("background:#0a74c4;color:white;")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(
            ":/images/images/tree-structure-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_3.setIcon(icon5)
        self.toolButton_3.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_3.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_3.setObjectName("toolButton_3")
        self.gridLayout.addWidget(self.toolButton_3, 1, 1, 1, 1)
        self.userSettingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.userSettingsToolButton.sizePolicy().hasHeightForWidth())
        self.userSettingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.userSettingsToolButton.setFont(font)
        self.userSettingsToolButton.setStyleSheet(
            "background:#0a74c4;color:white;")
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(
            ":/images/images/conference-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.userSettingsToolButton.setIcon(icon6)
        self.userSettingsToolButton.setIconSize(QtCore.QSize(256, 256))
        self.userSettingsToolButton.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextUnderIcon)
        self.userSettingsToolButton.setObjectName("toolButton_4")
        self.userSettingsToolButton.clicked.connect(self.open_user_settings)
        self.gridLayout.addWidget(self.userSettingsToolButton, 2, 2, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1332, 21))
        self.menubar.setObjectName("menubar")
        self.menu = QtWidgets.QMenu(self.menubar)
        self.menu.setObjectName("menu")
        self.menu_2 = QtWidgets.QMenu(self.menubar)
        self.menu_2.setObjectName("menu_2")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.action = QtWidgets.QAction(MainWindow)
        self.action.setIcon(icon5)
        self.action.setObjectName("action")
        self.action_2 = QtWidgets.QAction(MainWindow)
        self.action_2.setIcon(icon4)
        self.action_2.setObjectName("action_2")
        self.action_3 = QtWidgets.QAction(MainWindow)
        self.action_3.setIcon(icon3)
        self.action_3.setObjectName("action_3")
        self.userSettingsAction = QtWidgets.QAction(MainWindow)
        self.userSettingsAction.setIcon(icon6)
        self.userSettingsAction.setObjectName("action_4")
        self.userSettingsAction.triggered.connect(self.open_user_settings)
        self.action_6 = QtWidgets.QAction(MainWindow)
        self.action_6.setIcon(icon1)
        self.action_6.setObjectName("action_6")
        self.action_7 = QtWidgets.QAction(MainWindow)
        self.action_7.setIcon(icon2)
        self.action_7.setObjectName("action_7")
        self.aboutUs_menu = QtWidgets.QAction(MainWindow)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(":/images/images/favicon.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.aboutUs_menu.setIcon(icon7)
        self.aboutUs_menu.setObjectName("action_8")
        self.aboutUs_menu.triggered.connect(self.open_about_us)
        self.action_9 = QtWidgets.QAction(MainWindow)
        self.action_9.setObjectName("action_9")
        self.action_10 = QtWidgets.QAction(MainWindow)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(
            ":/images/images/phone-18-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_10.setIcon(icon8)
        self.action_10.setObjectName("action_10")
        self.menu.addAction(self.action)
        self.menu.addAction(self.action_2)
        self.menu.addAction(self.action_3)
        self.menu.addAction(self.userSettingsAction)
        self.menu.addSeparator()
        self.menu.addAction(self.action_6)
        self.menu.addAction(self.action_7)
        self.menu_2.addAction(self.aboutUs_menu)
        self.menu_2.addAction(self.action_10)
        self.menubar.addAction(self.menu.menuAction())
        self.menubar.addAction(self.menu_2.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def open_about_us(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = aboutUs.Ui_Dialog()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def open_user_settings(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = users_settings.Ui_Form()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate(
            "MainWindow", "Vision store manager - Innoventiq"))
        self.label.setText(_translate("MainWindow",
                                      "<html><head/><body><p><img src=\":/images/images/logo_small.png\"/></p></body></html>"))
        self.label_2.setText(_translate("MainWindow",
                                        "<html><head/><body><p><img src=\":/images/images/pos_logo_small.png\"/></p></body></html>"))
        self.settingsToolButton.setText(
            _translate("MainWindow", "إعدادت عامة "))
        self.toolButton_6.setText(_translate("MainWindow", "خروج "))
        self.toolButton.setText(_translate("MainWindow", "الحسابات"))
        self.toolButton_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.toolButton_3.setText(_translate("MainWindow", "المدخلات"))
        self.userSettingsToolButton.setText(_translate(
            "MainWindow", "إعدادات الموظفين و المستخدمين"))
        self.menu.setTitle(_translate("MainWindow", "ذهاب إلى"))
        self.menu_2.setTitle(_translate("MainWindow", "من نحن"))
        self.action.setText(_translate("MainWindow", "المدخلات"))
        self.action_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.action_3.setText(_translate("MainWindow", "الحسابات"))
        self.userSettingsAction.setText(_translate("MainWindow", "المستخدمين"))
        self.action_6.setText(_translate("MainWindow", "إعدادت البرنامج"))
        self.action_7.setText(_translate("MainWindow", "خروج من البرنامج"))
        self.aboutUs_menu.setText(_translate("MainWindow", "عن الشركة"))
        self.action_9.setText(_translate("MainWindow", "الرخصة الحالة"))
        self.action_10.setText(_translate("MainWindow", "الإتصال بنا"))

    @staticmethod
    def resource_path(relative_path):
        if hasattr(sys, '_MEIPASS'):
            return os.path.join(sys._MEIPASS, relative_path)
        return os.path.join(os.path.abspath("."), relative_path)

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    myStyle = 'Fusion'
    app.setStyle(myStyle)
    # The proxy style should be based on an existing style,
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.showMaximized()
    sys.exit(app.exec_())
</code>```

Spec file (I also enabled console for better debugging):

```<code># -*- mode: python -*-

block_cipher = None

a = Analysis(['main.py'],
             pathex=['E:\\Innoventiq\\vision_manager'],
             binaries=[],
             datas=[
             ('dlls/api-ms-win-core-console-l1-1-0.dll', '.'),
             ('./images/images/pos_logo.png','./images/images/')
             ],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='main',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True , icon='app.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=False,
               name='main')
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Created a simple app with PYQT5 and tried to compile it to .exe file, I created on window 10 pc and it works great there, but when I tried to move the software to Windows 7 ( with no python installed) it gave me this error :

here is my main.py file :

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog

import aboutUs
import users_settings

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1332, 933)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/images/pos_logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setLayoutDirection(QtCore.Qt.RightToLeft)
        MainWindow.setStyleSheet("background:#a1d0f4;")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 3, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 2, 3, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.settingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.settingsToolButton.sizePolicy().hasHeightForWidth())
        self.settingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.settingsToolButton.setFont(font)
        self.settingsToolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/images/images/cog-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.settingsToolButton.setIcon(icon1)
        self.settingsToolButton.setIconSize(QtCore.QSize(128, 128))
        self.settingsToolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.settingsToolButton.setObjectName("toolButton_5")
        self.verticalLayout.addWidget(self.settingsToolButton)
        self.toolButton_6 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton_6.sizePolicy().hasHeightForWidth())
        self.toolButton_6.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.toolButton_6.setFont(font)
        self.toolButton_6.setStyleSheet("background:#fe3636;color:white;")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/images/images/close-window-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_6.setIcon(icon2)
        self.toolButton_6.setIconSize(QtCore.QSize(128, 128))
        self.toolButton_6.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_6.setObjectName("toolButton_6")
        self.verticalLayout.addWidget(self.toolButton_6)
        self.gridLayout.addLayout(self.verticalLayout, 2, 0, 1, 2)
        self.toolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton.sizePolicy().hasHeightForWidth())
        self.toolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton.setFont(font)
        self.toolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(":/images/images/calculator-5-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton.setIcon(icon3)
        self.toolButton.setIconSize(QtCore.QSize(256, 256))
        self.toolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton.setObjectName("toolButton")
        self.gridLayout.addWidget(self.toolButton, 1, 3, 1, 1)
        self.toolButton_2 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton_2.sizePolicy().hasHeightForWidth())
        self.toolButton_2.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_2.setFont(font)
        self.toolButton_2.setStyleSheet("background:#0a74c4;color:white;")
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(":/images/images/store-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_2.setIcon(icon4)
        self.toolButton_2.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_2.setObjectName("toolButton_2")
        self.gridLayout.addWidget(self.toolButton_2, 1, 2, 1, 1)
        self.toolButton_3 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.toolButton_3.sizePolicy().hasHeightForWidth())
        self.toolButton_3.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_3.setFont(font)
        self.toolButton_3.setStyleSheet("background:#0a74c4;color:white;")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(":/images/images/tree-structure-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_3.setIcon(icon5)
        self.toolButton_3.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_3.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_3.setObjectName("toolButton_3")
        self.gridLayout.addWidget(self.toolButton_3, 1, 1, 1, 1)
        self.userSettingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.userSettingsToolButton.sizePolicy().hasHeightForWidth())
        self.userSettingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.userSettingsToolButton.setFont(font)
        self.userSettingsToolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(":/images/images/conference-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.userSettingsToolButton.setIcon(icon6)
        self.userSettingsToolButton.setIconSize(QtCore.QSize(256, 256))
        self.userSettingsToolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.userSettingsToolButton.setObjectName("toolButton_4")
        self.userSettingsToolButton.clicked.connect(self.open_user_settings)
        self.gridLayout.addWidget(self.userSettingsToolButton, 2, 2, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1332, 21))
        self.menubar.setObjectName("menubar")
        self.menu = QtWidgets.QMenu(self.menubar)
        self.menu.setObjectName("menu")
        self.menu_2 = QtWidgets.QMenu(self.menubar)
        self.menu_2.setObjectName("menu_2")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.action = QtWidgets.QAction(MainWindow)
        self.action.setIcon(icon5)
        self.action.setObjectName("action")
        self.action_2 = QtWidgets.QAction(MainWindow)
        self.action_2.setIcon(icon4)
        self.action_2.setObjectName("action_2")
        self.action_3 = QtWidgets.QAction(MainWindow)
        self.action_3.setIcon(icon3)
        self.action_3.setObjectName("action_3")
        self.userSettingsAction = QtWidgets.QAction(MainWindow)
        self.userSettingsAction.setIcon(icon6)
        self.userSettingsAction.setObjectName("action_4")
        self.userSettingsAction.triggered.connect(self.open_user_settings)
        self.action_6 = QtWidgets.QAction(MainWindow)
        self.action_6.setIcon(icon1)
        self.action_6.setObjectName("action_6")
        self.action_7 = QtWidgets.QAction(MainWindow)
        self.action_7.setIcon(icon2)
        self.action_7.setObjectName("action_7")
        self.aboutUs_menu = QtWidgets.QAction(MainWindow)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(":/images/images/favicon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.aboutUs_menu.setIcon(icon7)
        self.aboutUs_menu.setObjectName("action_8")
        self.aboutUs_menu.triggered.connect(self.open_about_us)
        self.action_9 = QtWidgets.QAction(MainWindow)
        self.action_9.setObjectName("action_9")
        self.action_10 = QtWidgets.QAction(MainWindow)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/images/images/phone-18-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_10.setIcon(icon8)
        self.action_10.setObjectName("action_10")
        self.menu.addAction(self.action)
        self.menu.addAction(self.action_2)
        self.menu.addAction(self.action_3)
        self.menu.addAction(self.userSettingsAction)
        self.menu.addSeparator()
        self.menu.addAction(self.action_6)
        self.menu.addAction(self.action_7)
        self.menu_2.addAction(self.aboutUs_menu)
        self.menu_2.addAction(self.action_10)
        self.menubar.addAction(self.menu.menuAction())
        self.menubar.addAction(self.menu_2.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def open_about_us(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = aboutUs.Ui_Dialog()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def open_user_settings(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = users_settings.Ui_Form()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Vision store manager - Innoventiq"))
        self.label.setText(_translate("MainWindow",
                                      "

"))
        self.label_2.setText(_translate("MainWindow",
                                        "

"))
        self.settingsToolButton.setText(_translate("MainWindow", "إعدادت عامة "))
        self.toolButton_6.setText(_translate("MainWindow", "خروج "))
        self.toolButton.setText(_translate("MainWindow", "الحسابات"))
        self.toolButton_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.toolButton_3.setText(_translate("MainWindow", "المدخلات"))
        self.userSettingsToolButton.setText(_translate("MainWindow", "إعدادات الموظفين و المستخدمين"))
        self.menu.setTitle(_translate("MainWindow", "ذهاب إلى"))
        self.menu_2.setTitle(_translate("MainWindow", "من نحن"))
        self.action.setText(_translate("MainWindow", "المدخلات"))
        self.action_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.action_3.setText(_translate("MainWindow", "الحسابات"))
        self.userSettingsAction.setText(_translate("MainWindow", "المستخدمين"))
        self.action_6.setText(_translate("MainWindow", "إعدادت البرنامج"))
        self.action_7.setText(_translate("MainWindow", "خروج من البرنامج"))
        self.aboutUs_menu.setText(_translate("MainWindow", "عن الشركة"))
        self.action_9.setText(_translate("MainWindow", "الرخصة الحالة"))
        self.action_10.setText(_translate("MainWindow", "الإتصال بنا"))

import rsc_rc

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    myStyle = 'Fusion'
    app.setStyle(myStyle)
    # The proxy style should be based on an existing style,
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.showMaximized()
    sys.exit(app.exec_())

and here is my main.spec:

# -*- mode: python -*-

block_cipher = None

a = Analysis(['main.py'],
             pathex=['E:\\Innoventiq\\vision_manager'],
             binaries=[],
             datas=[
             ('dlls/api-ms-win-core-console-l1-1-0.dll', '.'),
('dlls/api-ms-win-core-console-l1-1-0.dll','.'),
('dlls/api-ms-win-core-console-l1-2-0.dll','.'),
('dlls/api-ms-win-crt-math-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-stdio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-locale-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-heap-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-runtime-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-string-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-stdio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-heap-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-runtime-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-convert-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-math-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-process-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-conio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-filesystem-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-string-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-environment-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-time-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-stdio-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-locale-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-heap-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-runtime-l1-1-0.dll','.'),
('dlls/api-ms-win-crt-convert-l1-1-0.dll','.'),

             ],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='main',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=False , icon='app.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='main')

I used Pyinstaller to generate the file.

Body:
There are some problems with your code, and if you fix them I think your problem would be solved:

First, you need to load your external files (like *.ico in your example) properly when you want to freeze your script as one file executable. I added the first icon you can add all your other icons like that, also you can find more about that in a related question in here.

Second I suggest you disable UPX first because sometimes it can't properly bring standard PyQt DLL files with your project.

Third, I highly recommend you to build your project on Windows 7, and because of that, you don't need to feed api-ms-win*.dll as data files.

And last but not least make sure that your build and target architecture are the same (X64 or X86) and you already installed Visual C++ Redistributable on your Win7 target.

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog
import os
import sys
import rsc_rc
import aboutUs
import users_settings

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1332, 933)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(self.resource_path(
            "./images/images/pos_logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setLayoutDirection(QtCore.Qt.RightToLeft)
        MainWindow.setStyleSheet("background:#a1d0f4;")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 3, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 2, 3, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.settingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.settingsToolButton.sizePolicy().hasHeightForWidth())
        self.settingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.settingsToolButton.setFont(font)
        self.settingsToolButton.setStyleSheet(
            "background:#0a74c4;color:white;")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/images/images/cog-256.ico"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.settingsToolButton.setIcon(icon1)
        self.settingsToolButton.setIconSize(QtCore.QSize(128, 128))
        self.settingsToolButton.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextUnderIcon)
        self.settingsToolButton.setObjectName("toolButton_5")
        self.verticalLayout.addWidget(self.settingsToolButton)
        self.toolButton_6 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton_6.sizePolicy().hasHeightForWidth())
        self.toolButton_6.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.toolButton_6.setFont(font)
        self.toolButton_6.setStyleSheet("background:#fe3636;color:white;")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(
            ":/images/images/close-window-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_6.setIcon(icon2)
        self.toolButton_6.setIconSize(QtCore.QSize(128, 128))
        self.toolButton_6.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_6.setObjectName("toolButton_6")
        self.verticalLayout.addWidget(self.toolButton_6)
        self.gridLayout.addLayout(self.verticalLayout, 2, 0, 1, 2)
        self.toolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton.sizePolicy().hasHeightForWidth())
        self.toolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton.setFont(font)
        self.toolButton.setStyleSheet("background:#0a74c4;color:white;")
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(
            ":/images/images/calculator-5-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton.setIcon(icon3)
        self.toolButton.setIconSize(QtCore.QSize(256, 256))
        self.toolButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton.setObjectName("toolButton")
        self.gridLayout.addWidget(self.toolButton, 1, 3, 1, 1)
        self.toolButton_2 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton_2.sizePolicy().hasHeightForWidth())
        self.toolButton_2.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_2.setFont(font)
        self.toolButton_2.setStyleSheet("background:#0a74c4;color:white;")
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(":/images/images/store-256.ico"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_2.setIcon(icon4)
        self.toolButton_2.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_2.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_2.setObjectName("toolButton_2")
        self.gridLayout.addWidget(self.toolButton_2, 1, 2, 1, 1)
        self.toolButton_3 = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.toolButton_3.sizePolicy().hasHeightForWidth())
        self.toolButton_3.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(48)
        self.toolButton_3.setFont(font)
        self.toolButton_3.setStyleSheet("background:#0a74c4;color:white;")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(
            ":/images/images/tree-structure-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButton_3.setIcon(icon5)
        self.toolButton_3.setIconSize(QtCore.QSize(256, 256))
        self.toolButton_3.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolButton_3.setObjectName("toolButton_3")
        self.gridLayout.addWidget(self.toolButton_3, 1, 1, 1, 1)
        self.userSettingsToolButton = QtWidgets.QToolButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                           QtWidgets.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.userSettingsToolButton.sizePolicy().hasHeightForWidth())
        self.userSettingsToolButton.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Shorooq_N1")
        font.setPointSize(36)
        self.userSettingsToolButton.setFont(font)
        self.userSettingsToolButton.setStyleSheet(
            "background:#0a74c4;color:white;")
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(
            ":/images/images/conference-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.userSettingsToolButton.setIcon(icon6)
        self.userSettingsToolButton.setIconSize(QtCore.QSize(256, 256))
        self.userSettingsToolButton.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextUnderIcon)
        self.userSettingsToolButton.setObjectName("toolButton_4")
        self.userSettingsToolButton.clicked.connect(self.open_user_settings)
        self.gridLayout.addWidget(self.userSettingsToolButton, 2, 2, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1332, 21))
        self.menubar.setObjectName("menubar")
        self.menu = QtWidgets.QMenu(self.menubar)
        self.menu.setObjectName("menu")
        self.menu_2 = QtWidgets.QMenu(self.menubar)
        self.menu_2.setObjectName("menu_2")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.action = QtWidgets.QAction(MainWindow)
        self.action.setIcon(icon5)
        self.action.setObjectName("action")
        self.action_2 = QtWidgets.QAction(MainWindow)
        self.action_2.setIcon(icon4)
        self.action_2.setObjectName("action_2")
        self.action_3 = QtWidgets.QAction(MainWindow)
        self.action_3.setIcon(icon3)
        self.action_3.setObjectName("action_3")
        self.userSettingsAction = QtWidgets.QAction(MainWindow)
        self.userSettingsAction.setIcon(icon6)
        self.userSettingsAction.setObjectName("action_4")
        self.userSettingsAction.triggered.connect(self.open_user_settings)
        self.action_6 = QtWidgets.QAction(MainWindow)
        self.action_6.setIcon(icon1)
        self.action_6.setObjectName("action_6")
        self.action_7 = QtWidgets.QAction(MainWindow)
        self.action_7.setIcon(icon2)
        self.action_7.setObjectName("action_7")
        self.aboutUs_menu = QtWidgets.QAction(MainWindow)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(":/images/images/favicon.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.aboutUs_menu.setIcon(icon7)
        self.aboutUs_menu.setObjectName("action_8")
        self.aboutUs_menu.triggered.connect(self.open_about_us)
        self.action_9 = QtWidgets.QAction(MainWindow)
        self.action_9.setObjectName("action_9")
        self.action_10 = QtWidgets.QAction(MainWindow)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(
            ":/images/images/phone-18-256.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_10.setIcon(icon8)
        self.action_10.setObjectName("action_10")
        self.menu.addAction(self.action)
        self.menu.addAction(self.action_2)
        self.menu.addAction(self.action_3)
        self.menu.addAction(self.userSettingsAction)
        self.menu.addSeparator()
        self.menu.addAction(self.action_6)
        self.menu.addAction(self.action_7)
        self.menu_2.addAction(self.aboutUs_menu)
        self.menu_2.addAction(self.action_10)
        self.menubar.addAction(self.menu.menuAction())
        self.menubar.addAction(self.menu_2.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def open_about_us(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = aboutUs.Ui_Dialog()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def open_user_settings(self, checked=None):
        if checked is None:
            return
        dialog = QDialog()
        dialog.ui = users_settings.Ui_Form()
        dialog.ui.setupUi(dialog)
        dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        dialog.exec_()

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate(
            "MainWindow", "Vision store manager - Innoventiq"))
        self.label.setText(_translate("MainWindow",
                                      "<html><head/><body><p><img src=\":/images/images/logo_small.png\"/></p></body></html>"))
        self.label_2.setText(_translate("MainWindow",
                                        "<html><head/><body><p><img src=\":/images/images/pos_logo_small.png\"/></p></body></html>"))
        self.settingsToolButton.setText(
            _translate("MainWindow", "إعدادت عامة "))
        self.toolButton_6.setText(_translate("MainWindow", "خروج "))
        self.toolButton.setText(_translate("MainWindow", "الحسابات"))
        self.toolButton_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.toolButton_3.setText(_translate("MainWindow", "المدخلات"))
        self.userSettingsToolButton.setText(_translate(
            "MainWindow", "إعدادات الموظفين و المستخدمين"))
        self.menu.setTitle(_translate("MainWindow", "ذهاب إلى"))
        self.menu_2.setTitle(_translate("MainWindow", "من نحن"))
        self.action.setText(_translate("MainWindow", "المدخلات"))
        self.action_2.setText(_translate("MainWindow", "المخازن و الفروع"))
        self.action_3.setText(_translate("MainWindow", "الحسابات"))
        self.userSettingsAction.setText(_translate("MainWindow", "المستخدمين"))
        self.action_6.setText(_translate("MainWindow", "إعدادت البرنامج"))
        self.action_7.setText(_translate("MainWindow", "خروج من البرنامج"))
        self.aboutUs_menu.setText(_translate("MainWindow", "عن الشركة"))
        self.action_9.setText(_translate("MainWindow", "الرخصة الحالة"))
        self.action_10.setText(_translate("MainWindow", "الإتصال بنا"))

    @staticmethod
    def resource_path(relative_path):
        if hasattr(sys, '_MEIPASS'):
            return os.path.join(sys._MEIPASS, relative_path)
        return os.path.join(os.path.abspath("."), relative_path)

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    myStyle = 'Fusion'
    app.setStyle(myStyle)
    # The proxy style should be based on an existing style,
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.showMaximized()
    sys.exit(app.exec_())

Spec file (I also enabled console for better debugging):

# -*- mode: python -*-

block_cipher = None

a = Analysis(['main.py'],
             pathex=['E:\\Innoventiq\\vision_manager'],
             binaries=[],
             datas=[
             ('dlls/api-ms-win-core-console-l1-1-0.dll', '.'),
             ('./images/images/pos_logo.png','./images/images/')
             ],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='main',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True , icon='app.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=False,
               name='main')


问:
Swapping red with green, vice versa
I've been working on this problem for a while now and am not able to figure out what I need to fix my code. I should be able to swap the color red with green, but in my example I keep getting an error (I can set the red to green, but not vice versa. Can someone take a look at where I've gone wrong?</p>

```<code>function swapRedGreen(pixel){

pixel.setRed(pixel.getGreen());
pixel.setGreen(pixel.getRed());
}
var image = new SimpleImage("eastereggs.jpg");
print(image);
for(var pix of image.values()){
    swapRedGreen(pix);
}
print(image);
</code>```

答:
Here is the code i came up with to solve this problem. The approach is to create two variables, one is initialized with the red and the other one is initialized with the green and just swap them around later on.</p>

```<code>    var MyImage = new SimpleImage("eastereggs.jpg");
    print(MyImage);

    function swapRedGreen(pixel) {
        var newGreen = pixel.getRed();
        var newRed = pixel.getGreen();
        pixel.setGreen(newGreen);
        pixel.setRed(newRed);
        return pixel;
    }

    for (var pix of MyImage.values()){
        swapRedGreen(pix);
    }
    print(MyImage);
</code>```

ContentLicense: CC BY-SA 3.0

Title: Swapping red with green, vice versa

Body:
I've been working on this problem for a while now and am not able to figure out what I need to fix my code. I should be able to swap the color red with green, but in my example I keep getting an error (I can set the red to green, but not vice versa. Can someone take a look at where I've gone wrong?

function swapRedGreen(pixel){

pixel.setRed(pixel.getGreen());
pixel.setGreen(pixel.getRed());
}
var image = new SimpleImage("eastereggs.jpg");
print(image);
for(var pix of image.values()){
    swapRedGreen(pix);
}
print(image);

Body:
Here is the code i came up with to solve this problem. The approach is to create two variables, one is initialized with the red and the other one is initialized with the green and just swap them around later on.

    var MyImage = new SimpleImage("eastereggs.jpg");
    print(MyImage);

    function swapRedGreen(pixel) {
        var newGreen = pixel.getRed();
        var newRed = pixel.getGreen();
        pixel.setGreen(newGreen);
        pixel.setRed(newRed);
        return pixel;
    }

    for (var pix of MyImage.values()){
        swapRedGreen(pix);
    }
    print(MyImage);


问:
Get the data of Build.Repository.LocalPath and used it in my DockerFile
I want to get the data from the variable Build.Repository.LocalPath and use it in my Dockerfile, but it shows me and error.

This is my dockerfile:

```<code>FROM microsoft/aspnet:latest

COPY "/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/" /inetpub/wwwroot
</code>```

I get this error:

```<code>Step 2/9 : COPY "/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/" /inetpub/wwwroot
failed to process "\"/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/\"": missing ':' in substitution
##[error]C:\Program Files\Docker\docker.exe failed with return code: 1
</code>```

I have try a lot of ways, putting this line:

```<code>COPY "/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/" /inetpub/wwwroot
</code>```

答:
You can add in the Dockerfile an argument:

```<code>ARG path
</code>```

In the Azure DevOps Docker task add an argument:

```<code>-task: Docker@2
 inputs:
   command: build
   arguments: --build-arg path=$(Build.Repository.LocalPath)
</code>```

Now the Dockerfile know the variable value and you can use it, for example:

```<code>FROM ubuntu:latest
ARG path
ECHO $path
</code>```

Results:

```<code>Step 3/13 : RUN echo $path
---> Running in 213dsa3dacv
/home/vsts/work/1/s
</code>```

But if you will try to copy the appliaction in this way:

```<code>FROM microsoft/aspnet:latest
ARG path
COPY $path/README.md /inetpub/wwwroot
</code>```

You will get an error:

COPY faild: CreateFile \?\C:\ProgramData\docker\tmp\docker-builder437597591\_work\1\s\README.md: The system cannot find the path specified.

It's because the Docker build the image within a temporary folder and he copy the sources to there, but he doesn't copy the agent folders (_work/1/s) so the best way it's just put a relative path where the Dockerfile exist, for example (if the Dockerfile exist with the README.md):

```<code>FROM microsoft/aspnet:latest
COPY README.md /inetpub/wwwroot
</code>```

Body:
I want to get the data from the variable Build.Repository.LocalPath and use it in my Dockerfile, but it shows me and error.

This is my dockerfile:

FROM microsoft/aspnet:latest

COPY "/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/" /inetpub/wwwroot

I get this error:

Step 2/9 : COPY "/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/" /inetpub/wwwroot
failed to process "\"/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/\"": missing ':' in substitution
##[error]C:\Program Files\Docker\docker.exe failed with return code: 1

I have try a lot of ways, putting this line:

COPY "/${Build.Repository.LocalPath}/NH.Services.WebApi/bin/Release/Publish/" /inetpub/wwwroot

Body:
You can add in the Dockerfile an argument:

ARG path

In the Azure DevOps Docker task add an argument:

-task: Docker@2
 inputs:
   command: build
   arguments: --build-arg path=$(Build.Repository.LocalPath)

Now the Dockerfile know the variable value and you can use it, for example:

FROM ubuntu:latest
ARG path
ECHO $path

Results:

Step 3/13 : RUN echo $path
---> Running in 213dsa3dacv
/home/vsts/work/1/s

But if you will try to copy the appliaction in this way:

FROM microsoft/aspnet:latest
ARG path
COPY $path/README.md /inetpub/wwwroot

You will get an error:

COPY faild: CreateFile \?\C:\ProgramData\docker\tmp\docker-builder437597591\_work\1\s\README.md: The system cannot find the path specified.

It's because the Docker build the image within a temporary folder and he copy the sources to there, but he doesn't copy the agent folders (_work/1/s) so the best way it's just put a relative path where the Dockerfile exist, for example (if the Dockerfile exist with the README.md):

FROM microsoft/aspnet:latest
COPY README.md /inetpub/wwwroot


问:
Keyboard disappears when you submit a form
I am making real time chat app and when user types something in an input and submits a form(clicks a send button) a keyboard (virtual keyboard on mobile devices) disappear.

I want to keep the keyboard opened.

<form class="panel" action="">
  <input type="text" class="message" id="message" autocomplete="off" spellcheck="false">

  <button type="submit" class="send" id="send"></button>
</form>
```

答:
keyboard will close when the input element looses focus.

You can try setting the focus back to the input element on submit.

 https://jsfiddle.net/b6t540s9/


问:
Check if all points in a set lie on the same line
I'm given a list with coordinates of n points, let's say:

```<code>points = [(1, 2), (2, 3), (3, 4)]
</code>```

And I need to check if all of them lie on the same line. I also decided to consider 3 cases to avoid dividing by zero when x1 == x2.
So here's my code in Python:

```<code># 2 points always lie on a line
if n <= 2:
    print("yes")
else:
    # leave only unique points
    points = list(set(points))
    x1, y1 = points[0]
    x2, y2 = points[1]

    # if two points have the same x coordinate
    # then they lie on a vertical line and
    # all other points have to have the same x coordinate too
    if x2 == x1:
        for i in range(2, len(points)):
            if points[i][0] != x1:
                print("no")
                break
        else: print("yes")

    # same with a horizontal line
    elif y2 == y1:
        for i in range(2, len(points)):
            if points[i][1] != y1:
                print("no")
                break
        else: print("yes")

    else:
        a = (y2-y1)/(x2-x1)
        b = y2 - a * x2

        for i in range(2, len(points)):
            x, y = points[i]
            if (y != a * x + b):
                print("no")
                break
        else: print("yes")
</code>```

It seems that I have a mistake somewhere in the code but I don't really understand what it is.

答:
Using cross product of vectors eliminates the complexity of having to deal with special cases where division by zero might happen. Three points are collinear if the cross product of the vectors formed by the two vectors defined by the 3 points is equal to zero:</p>

```<code>import math

class Point:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

class Vector:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

def are_collinear(three_points):
    a, b, c = three_points
    # better use math.isclose than == to check for floats
    return math.isclose((b-a).cross(c-a), 0.0)

points = [Point(1, 2), Point(2, 3), Point(3, 4)]
print(are_collinear(points))
# True

points = [Point(1, 2), Point(3, 3), Point(3, 4)]
print(are_collinear(points))
# False
</code>```

Body:
I'm given a list with coordinates of n points, let's say:

points = [(1, 2), (2, 3), (3, 4)]

And I need to check if all of them lie on the same line. I also decided to consider 3 cases to avoid dividing by zero when x1 == x2.
So here's my code in Python:

# 2 points always lie on a line
if n <= 2:
    print("yes")
else:
    # leave only unique points
    points = list(set(points))
    x1, y1 = points[0]
    x2, y2 = points[1]

    # if two points have the same x coordinate
    # then they lie on a vertical line and
    # all other points have to have the same x coordinate too
    if x2 == x1:
        for i in range(2, len(points)):
            if points[i][0] != x1:
                print("no")
                break
        else: print("yes")

    # same with a horizontal line
    elif y2 == y1:
        for i in range(2, len(points)):
            if points[i][1] != y1:
                print("no")
                break
        else: print("yes")

    else:
        a = (y2-y1)/(x2-x1)
        b = y2 - a * x2

        for i in range(2, len(points)):
            x, y = points[i]
            if (y != a * x + b):
                print("no")
                break
        else: print("yes")

It seems that I have a mistake somewhere in the code but I don't really understand what it is.

Body:
Using cross product of vectors eliminates the complexity of having to deal with special cases where division by zero might happen. Three points are collinear if the cross product of the vectors formed by the two vectors defined by the 3 points is equal to zero:

import math

class Point:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

class Vector:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

def are_collinear(three_points):
    a, b, c = three_points
    # better use math.isclose than == to check for floats
    return math.isclose((b-a).cross(c-a), 0.0)

points = [Point(1, 2), Point(2, 3), Point(3, 4)]
print(are_collinear(points))
# True

points = [Point(1, 2), Point(3, 3), Point(3, 4)]
print(are_collinear(points))
# False


问:
Calling a Range (as a variable) in a different Worksheet
So, I have set a Range as a variable

```<code>Set Range_Count = Range("A2", Range("A2").End(xlDown))
</code>```

And now I'm trying to call it in a WorksheetFunction using VBA without needing to select the worksheet

```<code>'This is what I don't want to do anymore
Sheets(1).Select
Count_Product = Application.WorksheetFunction.CountIf(Range_Count, "<>")

'This is what I'm wondering if it's possible to be done
Count_Product = Application.WokrsheetFunction.CountIf(Sheets(2).Range_Count, "<>")
</code>```

But It doesn't seem to work. Is there a way to do this?

答:
This is how it works:</p>

```<code>Set Range_Count = Sheets(2).Range("A2", Range("A2").End(xlDown)) 'full qualify the range with it's sheet
Count_Product = Application.WorksheetFunction.CountIf(Range_Count, "<>") 'then use the range
</code>```

Body:
So, I have set a Range as a variable

Set Range_Count = Range("A2", Range("A2").End(xlDown))

And now I'm trying to call it in a WorksheetFunction using VBA without needing to select the worksheet

'This is what I don't want to do anymore
Sheets(1).Select
Count_Product = Application.WorksheetFunction.CountIf(Range_Count, "<>")

'This is what I'm wondering if it's possible to be done
Count_Product = Application.WokrsheetFunction.CountIf(Sheets(2).Range_Count, "<>")

But It doesn't seem to work. Is there a way to do this?

Body:
This is how it works:

Set Range_Count = Sheets(2).Range("A2", Range("A2").End(xlDown)) 'full qualify the range with it's sheet
Count_Product = Application.WorksheetFunction.CountIf(Range_Count, "<>") 'then use the range


问:
Create table and insert two records SQL using python
I'm trying to create a table on a tempdb database on a local server KHBW001 using MSSQL. My code is:

```<code>import pyodbc

connection = pyodbc.connect('Driver={SQL Server};'
                      'Server=KHBW001;'
                      'Database=tempdb;'
                      'Trusted_Connection=yes;')

cursor = connection.cursor()
cursor.executemany(
    "CREATE TABLE tempdb.dbo.NewTestPyTable(Symbol varchar(15), Shares integer, Price double)")  # creates new table

cursor.executemany("""
                INSERT INTO tempdb.dbo.NewTestPyTable (Symbol, Shares, Price)
                VALUES
                [('ETH',55,199.55),
                ('KHC',66,33.5)]
                """)  # insert two records into new table

connection.commit()
</code>```

I'm getting the error:

"CREATE TABLE tempdb.dbo.NewTestPyTable(Symbol varchar(15), Shares
  integer, Price double)")  # creates new table

TypeError: function takes exactly 2 arguments (1 given)

I don't quite understand what I'm doing wrong. Please assist

答:
Figured it out...</p>

```<code>import pyodbc

connection = pyodbc.connect('Driver={SQL Server};'
                      'Server=KHBW001;'
                      'Database=tempdb;'
                      'Trusted_Connection=yes;')

cursor = connection.cursor()
cursor.execute(
    "CREATE TABLE NewTestPyTable(Symbol varchar(15), Shares integer, Price integer)")  # creates new table
params = [('ETH', 55, 199),
          ('KHC', 66, 33)]
# insert two records into new table
cursor.executemany(
    "INSERT INTO tempdb.dbo.NewTestPyTable (Symbol, Shares, Price) VALUES (?, ?, ?)", params)

connection.commit()
</code>```

Body:
I'm trying to create a table on a tempdb database on a local server KHBW001 using MSSQL. My code is:

import pyodbc

connection = pyodbc.connect('Driver={SQL Server};'
                      'Server=KHBW001;'
                      'Database=tempdb;'
                      'Trusted_Connection=yes;')

cursor = connection.cursor()
cursor.executemany(
    "CREATE TABLE tempdb.dbo.NewTestPyTable(Symbol varchar(15), Shares integer, Price double)")  # creates new table

cursor.executemany("""
                INSERT INTO tempdb.dbo.NewTestPyTable (Symbol, Shares, Price)
                VALUES
                [('ETH',55,199.55),
                ('KHC',66,33.5)]
                """)  # insert two records into new table

connection.commit()

I'm getting the error:

"CREATE TABLE tempdb.dbo.NewTestPyTable(Symbol varchar(15), Shares
  integer, Price double)")  # creates new table

TypeError: function takes exactly 2 arguments (1 given)

I don't quite understand what I'm doing wrong. Please assist

Body:
Figured it out...

import pyodbc

connection = pyodbc.connect('Driver={SQL Server};'
                      'Server=KHBW001;'
                      'Database=tempdb;'
                      'Trusted_Connection=yes;')

cursor = connection.cursor()
cursor.execute(
    "CREATE TABLE NewTestPyTable(Symbol varchar(15), Shares integer, Price integer)")  # creates new table
params = [('ETH', 55, 199),
          ('KHC', 66, 33)]
# insert two records into new table
cursor.executemany(
    "INSERT INTO tempdb.dbo.NewTestPyTable (Symbol, Shares, Price) VALUES (?, ?, ?)", params)

connection.commit()


问:
Find the minimum of a sorted and shifted array with better than O(n) time complexity
We have an assignment to search for the minimum element of a sorted array that is shifted to the right afterwards. For example: [1, 5, 6, 19, 56, 101] becomes [19, 56, 101, 1, 5, 6]. The method should be implemented using a divide and conquer algorithm and it should have a better asymptotic time complexity than O(n).
EDIT: I forgot to add that the elements int the array are unique.

I already implemented a method and wanted to ask if this is better than O(n) and if there are ways to improve my method.

```<code>public class FindMinimum {
    public void findMinimum(int[] arr) {

        // the recursive method ends when the length of the array is smaller than 2
        if (arr.length < 2) {
            return;
        }

        int mid = arr.length / 2;

        /*
         * if the array length is greater or the same as two, check if the middle
         * element is smaller as the element before that. And print the middle element
         * if it's true.
         */
        if (arr.length >= 2) {
            if (arr[mid - 1] > arr[mid]) {
                System.out.println("Minimum: " + arr[mid]);
                return;
            }
        }

        /*
         * separate the array in two sub-arrays through the middle and start the method
         * with those two arrays again.
         */
        int[] leftArr = new int[mid];
        int[] rightArr = new int[arr.length - mid];
        for (int i = 0; i < mid; i++) {
            leftArr[i] = arr[i];
        }
        for (int i = mid; i < arr.length; i++) {
            rightArr[i - mid] = arr[i];
        }
        findMinimum(leftArr);
        findMinimum(rightArr);
    }
}
</code>```

答:
This is my new solution, without copying the array anywhere. </p>

```<code>public class FindMinimum {

    public void findMinimum(int[] arr) {
        findMinimumSub(arr, 0, arr.length - 1, 2);
    }

    private void findMinimumSub(int[] arr, int start, int end, int size) {
        // the recursive method ends when the length of the array is smaller than 2
        if ((end - start) < 2) {
            if (arr[end] > arr[start])
                System.out.println("Minimum: " + arr[start]);
            else
                System.out.println("Minimum: " + arr[end]);
            return;
        }

        int mid = arr.length / size;

        if (arr[start] > arr[end]) {
            // right side
            start += mid;
            findMinimumSub(arr, start, end, size * 2);
        }
        else {
            // left side
            findMinimumSub(arr, start, mid, size * 2);
        }
    }
}
</code>```

Body:
We have an assignment to search for the minimum element of a sorted array that is shifted to the right afterwards. For example: [1, 5, 6, 19, 56, 101] becomes [19, 56, 101, 1, 5, 6]. The method should be implemented using a divide and conquer algorithm and it should have a better asymptotic time complexity than O(n).
EDIT: I forgot to add that the elements int the array are unique.

I already implemented a method and wanted to ask if this is better than O(n) and if there are ways to improve my method.

public class FindMinimum {
    public void findMinimum(int[] arr) {

        // the recursive method ends when the length of the array is smaller than 2
        if (arr.length < 2) {
            return;
        }

        int mid = arr.length / 2;

        /*
         * if the array length is greater or the same as two, check if the middle
         * element is smaller as the element before that. And print the middle element
         * if it's true.
         */
        if (arr.length >= 2) {
            if (arr[mid - 1] > arr[mid]) {
                System.out.println("Minimum: " + arr[mid]);
                return;
            }
        }

        /*
         * separate the array in two sub-arrays through the middle and start the method
         * with those two arrays again.
         */
        int[] leftArr = new int[mid];
        int[] rightArr = new int[arr.length - mid];
        for (int i = 0; i < mid; i++) {
            leftArr[i] = arr[i];
        }
        for (int i = mid; i < arr.length; i++) {
            rightArr[i - mid] = arr[i];
        }
        findMinimum(leftArr);
        findMinimum(rightArr);
    }
}

Body:
This is my new solution, without copying the array anywhere.

public class FindMinimum {

    public void findMinimum(int[] arr) {
        findMinimumSub(arr, 0, arr.length - 1, 2);
    }

    private void findMinimumSub(int[] arr, int start, int end, int size) {
        // the recursive method ends when the length of the array is smaller than 2
        if ((end - start) < 2) {
            if (arr[end] > arr[start])
                System.out.println("Minimum: " + arr[start]);
            else
                System.out.println("Minimum: " + arr[end]);
            return;
        }

        int mid = arr.length / size;

        if (arr[start] > arr[end]) {
            // right side
            start += mid;
            findMinimumSub(arr, start, end, size * 2);
        }
        else {
            // left side
            findMinimumSub(arr, start, mid, size * 2);
        }
    }
}


问:
Dictionary size reduces upon increasing one element
I ran this:

```<code>import sys

diii = {'key1':1,'key2':2,'key3':1,'key4':2,'key5':1,'key6':2,'key7':1}
print sys.getsizeof(diii)
# output: 1048

diii = {'key1':1,'key2':2,'key3':1,'key4':2,'key5':1,'key6':2,'key7':1,'key8':2}
print sys.getsizeof(diii)
# output: 664
</code>```

Before asking here, I restarted my python shell and tried it online too and got the same result.

I thought a dictionary with one more element will either give same bytes as output or more, than the one containing one less element.

Any idea what am I doing wrong?

答:
sys.getsizeof returns the memory allocated to the underlying hash table implementation of those dictionaries, which has a somewhat non-obvious relationship with the actual size of the dictionary.

The CPython implementation of Python 2.7 quadruples the amount of memory allocated to a hash table each time it's filled up to 2/3 of its capacity, but shrinks it if it has over allocated memory to it (i.e. a large contiguous block of memory has been allocated but only a few addresses were actually used).

It just so happens that dictionaries that have between 8 and 11 elements allocate just enough memory for CPython to consider them 'over-allocated', and get shrunk.

Body:
I ran this:

import sys

diii = {'key1':1,'key2':2,'key3':1,'key4':2,'key5':1,'key6':2,'key7':1}
print sys.getsizeof(diii)
# output: 1048

diii = {'key1':1,'key2':2,'key3':1,'key4':2,'key5':1,'key6':2,'key7':1,'key8':2}
print sys.getsizeof(diii)
# output: 664

Before asking here, I restarted my python shell and tried it online too and got the same result.

I thought a dictionary with one more element will either give same bytes as output or more, than the one containing one less element.

Any idea what am I doing wrong?


问:
Initial value in dart class
I want to implement a points method, when user press on a button he earn some points.
my class look like this:

```<code>class User {
  String userEmail;
  String id;
  String token;
  String access;
  int points;

    User({
      @required this.userEmail,
      @required this.id,
      @required this.token,
      @required this.access,
      this.points = 0,
    });

  void raisePoints() {
    points = points + 2;
  }
}
</code>```

This is how i initlaize the user when he sign in:

_

```<code>authUser = User(
        id: fireUser.uid,
        userEmail: fireUser.email,
        token: token,
        access: googleSignInAuthentication.accessToken)
</code>```

How do i set the value of points to zero at the first time he signed in, and how I set the amount of the points when the user sign in?

答:
To set the initial value, you can use

```<code>User({
  @required this.userEmail,
  @required this.id,
  @required this.token,
  @required this.access,
  this.points = 0, // <-- set to 0
});
</code>```

And once you have created the user, you can increment/decrement points like:

```<code>User user = User(userEmail: "hi@gmail.com", id: "1", access: "true", token: "123");
user.points = 10;
</code>```

or you can use

```<code>user.raisePoints();
</code>```

Title: Initial value in dart class

Body:
I want to implement a points method, when user press on a button he earn some points.
my class look like this:

class User {
  String userEmail;
  String id;
  String token;
  String access;
  int points;

    User({
      @required this.userEmail,
      @required this.id,
      @required this.token,
      @required this.access,
      this.points = 0,
    });

  void raisePoints() {
    points = points + 2;
  }
}

This is how i initlaize the user when he sign in:

_

authUser = User(
        id: fireUser.uid,
        userEmail: fireUser.email,
        token: token,
        access: googleSignInAuthentication.accessToken)

How do i set the value of points to zero at the first time he signed in, and how I set the amount of the points when the user sign in?

Body:
To set the initial value, you can use

User({
  @required this.userEmail,
  @required this.id,
  @required this.token,
  @required this.access,
  this.points = 0, // <-- set to 0
});

And once you have created the user, you can increment/decrement points like:

User user = User(userEmail: "hi@gmail.com", id: "1", access: "true", token: "123");
user.points = 10;

or you can use

user.raisePoints();


问:
Sorting of Date String using sortUsingDescriptors?
I have number of arrays of dictionary

```<code>   points = 200;
   startDate = "Jun 04, 2011, 13:15 PM";

   points = 200;
   startDate = "May 01, 2011, 11:15 PM";

   and  -------
</code>```

I have to do sorting on the basis of startDate.

I have used number of sorting's earlier like numerical.. alphabetical sorting etc via this method:

```<code>-(NSMutableArray*)SortEventsArray:(NSMutableArray*)arrayToSort :(NSString*)sortExpression
{
   NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:sortExpression ascending:YES];
   [arrayToSort sortUsingDescriptors:[NSMutableArray arrayWithObject:mySorter]];
   return arrayToSort;
}
</code>```

but its not working for Date string.

Please help

答:
Chekout this

This one also

Both will help you.

Body:
I have number of arrays of dictionary

   points = 200;
   startDate = "Jun 04, 2011, 13:15 PM";

   points = 200;
   startDate = "May 01, 2011, 11:15 PM";

   and  -------

I have to do sorting on the basis of startDate.

I have used number of sorting's earlier like numerical.. alphabetical sorting etc via this method:

-(NSMutableArray*)SortEventsArray:(NSMutableArray*)arrayToSort :(NSString*)sortExpression
{
   NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:sortExpression ascending:YES];
   [arrayToSort sortUsingDescriptors:[NSMutableArray arrayWithObject:mySorter]];
   return arrayToSort;
}

but its not working for Date string.

Please help