我有一个 pyinstaller exe 程序,我用它来在我的超级锁定的学校发行的 Windows 笔记本电脑上运行我的 python 程序。当我在学校计算机上运行它时,我收到弹出窗口:“此应用程序已被您的系统管理员阻止。”
我制作了一个安装程序,但它也被阻止了。我还尝试编辑一些白名单文件来运行我的应用程序,但这也不起作用。我不明白一些安装程序(例如 rainmeter 安装程序)是如何工作的,但我的却不行,因为 rainmeter 绝对没有列入白名单。我想知道是否有办法绕过 AppLocker,以便我可以安装我的程序。
如果有帮助,这是我的Python程序。这是一个股票交易应用程序,连接到我桌面上的服务器来运行算法。
from datetime import datetime
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import customtkinter as tk
# sets apperence properties for the window
tk.set_appearance_mode("dark")
tk.set_default_color_theme("green")
class App(tk.CTk):
def __init__(self):
super().__init__()
self.configureWindow()
self.declareSidebarFrame()
self.declareGraph()
self.declareTabView()
self.declareBuyingFrame()
def configureWindow(self):
self.title("BuyIn")
self.resizable(False, False)
# sets properties for the window
tk.set_appearance_mode("dark")
tk.set_default_color_theme("green")
def changeAppearanceMode(self, newAppearanceMode):
tk.set_appearance_mode(newAppearanceMode)
# change graph color
if tk.get_appearance_mode() == "Light":
facecolor = "#ebebeb"
tick_label_color = "black"
self.plot.plot(color="#2fa572")
else:
facecolor = "#242424"
tick_label_color = "white"
self.plot.plot(color="#2fa572")
self.fig.set_facecolor(facecolor)
self.plot.set_facecolor(facecolor)
self.plot.tick_params(labelcolor=tick_label_color)
self.canvas.draw()
def declareSidebarFrame(self):
# declare sidebar frame
self.sidebarFrame = tk.CTkFrame(self, width=140, corner_radius=0)
self.sidebarFrame.grid(rowspan=2, row=0, column=0, sticky="nsew")
self.sidebarFrame.grid_rowconfigure(2, weight=1)
# declare app title
self.logoLabel = tk.CTkLabel(
self.sidebarFrame,
text="Buy In\nbeta",
font=tk.CTkFont(size=20, weight="bold"),
)
self.logoLabel.grid(row=0, column=0, padx=20, pady=10)
# create app apperence modes
self.appearanceModeLabel = tk.CTkLabel(
self.sidebarFrame, text="Appearance Mode:"
)
self.appearanceModeLabel.grid(row=3, column=0, padx=20, pady=(0, 10))
self.appearanceModeOptionMenu = tk.CTkOptionMenu(
self.sidebarFrame,
values=["Light", "Dark"],
command=self.changeAppearanceMode,
)
self.appearanceModeOptionMenu.grid(
row=4, column=0, padx=20, pady=(0, 10))
def declareGraph(self):
self.fig = Figure(figsize=(5, 5), dpi=100)
self.plot = self.fig.add_subplot(111)
self.canvas = FigureCanvasTkAgg(self.fig, self)
self.fig.set_facecolor("#242424")
self.plot.set_facecolor("#242424")
self.plot.tick_params(labelcolor="white")
self.plot.plot(color="#2fa572")
self.plot.axes.get_xaxis().set_visible(False)
self.canvas.get_tk_widget().grid(row=0, column=1, rowspan=2, sticky=tk.NSEW)
def declareTabView(self):
self.tabview = tk.CTkTabview(self, width=400)
self.tabview.grid(row=0, column=2, padx=(0, 20), pady=(10, 0))
self.tabview.add("Stock Trading")
self.tabview.add("Crypto Trading")
self.tabview.add("Auto Trading")
# declare 'Stock Trading' objects
self.dtTickerEntryBox = tk.CTkEntry(
self.tabview.tab("Stock Trading"), placeholder_text="Ticker"
)
self.dtTickerEntryBox.grid(row=0, column=0, padx=10, pady=(10, 0))
self.dtDurationBox = tk.CTkOptionMenu(
self.tabview.tab("Stock Trading"),
values=["60m", "3h", "6h", "12h", "1d", "3d"],
)
self.dtDurationBox.grid(row=1, column=0, padx=10, pady=(10, 0))
self.dtDurationBox.set("3h")
self.dtButton = tk.CTkButton(
self.tabview.tab("Stock Trading"),
text="Find Matches",
command=self.stockTradingAlgorithem,
)
self.dtButton.grid(row=2, column=0, padx=10, pady=(10, 0))
self.dtDataSizeLabel = tk.CTkLabel(
self.tabview.tab("Stock Trading"), text="Database Size - Result Size"
)
self.dtDataSizeLabel.grid(
row=0, column=1, columnspan=2, padx=0, pady=(10, 0))
self.dtDataSizeSlider = tk.CTkSlider(
self.tabview.tab("Stock Trading"), from_=1, to=100
)
self.dtDataSizeSlider.grid(
row=1, column=1, columnspan=2, padx=10, pady=(10, 0))
self.dtResultSizeSlider = tk.CTkSlider(
self.tabview.tab("Stock Trading"), from_=1, to=20
)
self.dtResultSizeSlider.grid(
row=2, column=1, columnspan=2, padx=10, pady=(10, 0)
)
self.dtResultSizeSlider.configure(number_of_steps=4)
self.dtGraphModeLabel = tk.CTkLabel(
self.tabview.tab("Stock Trading"), text="Graph Mode"
)
self.dtGraphModeLabel.grid(row=3, column=2, padx=10, pady=(10, 0))
self.dtRepeatAlgorithemVariable = tk.IntVar(value=0)
self.dtRepeatAlgorithem = tk.CTkRadioButton(
self.tabview.tab("Stock Trading"),
text="Repeat Graph",
variable=self.dtRepeatAlgorithemVariable,
value=0,
)
self.dtRepeatAlgorithem.grid(row=4, column=2, padx=10, sticky="w")
self.dtSingleAlgorithem = tk.CTkRadioButton(
self.tabview.tab("Stock Trading"),
text="Run Once",
variable=self.dtRepeatAlgorithemVariable,
value=1,
)
self.dtSingleAlgorithem.grid(row=5, column=2, padx=10, sticky="w")
global dtLiveAlgorithemUpdates
dtLiveAlgorithemUpdates = tk.CTkTextbox(
self.tabview.tab("Stock Trading"), width=225, height=100
)
dtLiveAlgorithemUpdates.grid(
row=3, rowspan=3, column=0, columnspan=2, padx=10, pady=10
)
# declare 'Crypto Trading' objects
self.ctTickerEntryBox = tk.CTkEntry(
self.tabview.tab("Crypto Trading"), placeholder_text="Ticker"
)
self.ctTickerEntryBox.grid(row=0, column=0, padx=10, pady=(10, 0))
self.ctDurationBox = tk.CTkOptionMenu(
self.tabview.tab("Crypto Trading"), values=["60m", "3h", "6h", "12h"]
)
self.ctDurationBox.grid(row=1, column=0, padx=10, pady=(10, 0))
self.ctDurationBox.set("3h")
self.ctButton = tk.CTkButton(
self.tabview.tab("Crypto Trading"),
text="Find Matches",
command=self.cryptoTradingAlgorithem,
)
self.ctButton.grid(row=2, column=0, padx=10, pady=(10, 0))
self.ctDataSizeLabel = tk.CTkLabel(
self.tabview.tab("Crypto Trading"), text="Database Size - Result Size"
)
self.ctDataSizeLabel.grid(
row=0, column=1, columnspan=2, padx=0, pady=(10, 0))
self.ctDataSizeSlider = tk.CTkSlider(
self.tabview.tab("Crypto Trading"), from_=1, to=3
)
self.ctDataSizeSlider.grid(
row=1, column=1, columnspan=2, padx=10, pady=(10, 0))
self.ctResultSizeSlider = tk.CTkSlider(
self.tabview.tab("Crypto Trading"), from_=1, to=20
)
self.ctResultSizeSlider.grid(
row=2, column=1, columnspan=2, padx=10, pady=(10, 0)
)
self.ctResultSizeSlider.configure(number_of_steps=4)
self.ctGraphModeLabel = tk.CTkLabel(
self.tabview.tab("Crypto Trading"), text="Graph Mode"
)
self.ctGraphModeLabel.grid(row=3, column=2, padx=10, pady=(10, 0))
self.ctRepeatAlgorithemVariable = tk.IntVar(value=0)
self.ctRepeatAlgorithem = tk.CTkRadioButton(
self.tabview.tab("Crypto Trading"),
text="Repeat Graph",
variable=self.ctRepeatAlgorithemVariable,
value=0,
)
self.ctRepeatAlgorithem.grid(row=4, column=2, padx=10, sticky="w")
self.ctSingleAlgorithem = tk.CTkRadioButton(
self.tabview.tab("Crypto Trading"),
text="Run Once",
variable=self.ctRepeatAlgorithemVariable,
value=1,
)
self.ctSingleAlgorithem.grid(row=5, column=2, padx=10, sticky="w")
global ctLiveAlgorithemUpdates
ctLiveAlgorithemUpdates = tk.CTkTextbox(
self.tabview.tab("Crypto Trading"), width=225, height=100
)
ctLiveAlgorithemUpdates.grid(
row=3, rowspan=3, column=0, columnspan=2, padx=10, pady=10
)
# declare 'Auto Trading' objects
self.atTickerEntryBox = tk.CTkEntry(
self.tabview.tab("Auto Trading"), placeholder_text="Ticker"
)
self.atTickerEntryBox.grid(row=0, column=0, padx=10, pady=(10, 0))
self.atButton = tk.CTkButton(
self.tabview.tab("Auto Trading"),
text="Start Auto Trading",
command=self.autoTradingAlgorithem,
)
self.atButton.grid(row=1, column=0, padx=10, pady=(10, 0))
self.atButton = tk.CTkButton(
self.tabview.tab("Auto Trading"),
text="Stop Auto Trading",
fg_color="#3b3b3b",
)
self.atButton.grid(row=2, column=0, padx=10, pady=(10, 0))
self.atDataSizeLabel = tk.CTkLabel(
self.tabview.tab("Auto Trading"), text="Database Size - Result Size"
)
self.atDataSizeLabel.grid(
row=0, column=1, columnspan=2, padx=0, pady=(10, 0))
self.atDataSizeSlider = tk.CTkSlider(
self.tabview.tab("Auto Trading"), from_=1, to=100
)
self.atDataSizeSlider.grid(
row=1, column=1, columnspan=2, padx=10, pady=(10, 0))
self.atResultSizeSlider = tk.CTkSlider(
self.tabview.tab("Auto Trading"), from_=1, to=20
)
self.atResultSizeSlider.grid(
row=2, column=1, columnspan=2, padx=10, pady=(10, 0)
)
self.atResultSizeSlider.configure(number_of_steps=4)
self.atTradingModeLabel = tk.CTkLabel(
self.tabview.tab("Auto Trading"), text="Trading Mode"
)
self.atTradingModeLabel.grid(row=3, column=2, padx=10, pady=(10, 0))
self.tradingMode = tk.IntVar(value=0)
self.atPaperTradingButton = tk.CTkRadioButton(
self.tabview.tab("Auto Trading"),
text="Paper Trading",
variable=self.tradingMode,
value=0,
)
self.atPaperTradingButton.grid(row=4, column=2, padx=10, sticky="w")
self.atLiveTradingButton = tk.CTkRadioButton(
self.tabview.tab("Auto Trading"),
text="Live Trading",
variable=self.tradingMode,
value=1,
)
self.atLiveTradingButton.grid(row=5, column=2, padx=10, sticky="w")
global atLiveTradingUpdates
atLiveTradingUpdates = tk.CTkTextbox(
self.tabview.tab("Auto Trading"), width=225, height=100
)
atLiveTradingUpdates.grid(
row=3, rowspan=3, column=0, columnspan=2, padx=10, pady=10
)
def declareBuyingFrame(self):
# declare buying frame
self.buyingFrame = tk.CTkFrame(self, width=400)
self.buyingFrame.grid(
row=1, column=2, padx=(0, 20), pady=(10, 40), sticky="nsew"
)
# declare stock purchasing objects
self.tickerEntryBoxLabel = tk.CTkLabel(
self.buyingFrame, text="Stock Ticker")
self.tickerEntryBoxLabel.grid(row=0, column=0, padx=10)
self.tickerEntryBox = tk.CTkEntry(
self.buyingFrame, width=125, state="disabled")
self.tickerEntryBox.grid(row=1, column=0, padx=10)
self.sharesEntryBoxLabel = tk.CTkLabel(
self.buyingFrame, text="Quantity")
self.sharesEntryBoxLabel.grid(row=2, column=0, padx=10)
self.sharesEntryBox = tk.CTkEntry(
self.buyingFrame, width=125, state="disabled")
self.sharesEntryBox.grid(row=3, column=0, padx=10)
self.orderTypeBoxLabel = tk.CTkLabel(
self.buyingFrame, text="Order Type")
self.orderTypeBoxLabel.grid(row=0, column=1, padx=10)
self.orderTypeBox = tk.CTkOptionMenu(
self.buyingFrame,
values=["Limit", "Market", "Stop"],
width=125,
state="disabled",
)
self.orderTypeBox.grid(row=1, column=1, padx=10)
self.Button = tk.CTkButton(
self.buyingFrame,
text="Buy Stock",
width=125,
command=self.stockTradingAlgorithem,
state="disabled",
)
self.Button.grid(row=3, column=1, padx=10)
# declare stock purchasing mode objects
self.tradingModeLabel = tk.CTkLabel(
self.buyingFrame, text="Trading Mode")
self.tradingModeLabel.grid(row=1, column=2, padx=10)
self.tradingMode = tk.IntVar(value=0)
self.paperMode = tk.CTkRadioButton(
self.buyingFrame, text="Paper", variable=self.tradingMode, value=0
)
self.paperMode.grid(row=2, column=2, padx=(10, 0),
pady=(10, 0), sticky="w")
self.liveMode = tk.CTkRadioButton(
self.buyingFrame, text="Live", variable=self.tradingMode, value=1
)
self.liveMode.grid(row=3, column=2, padx=(
10, 0), pady=(10, 0), sticky="w")
def serverRequest(self, settings):
import socket
# Define the server's external IP address and port
server_external_ip = '192.168.50.43'
server_port = 12345
# Create a socket and connect to the server
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((server_external_ip, server_port))
try:
# Send data to the server for evaluation
client_socket.send(settings.encode())
# Receive the result from the server
result = client_socket.recv(1024).decode()
print(f"Received result from server: {result}")
except Exception as e:
print(f"Error: {e}")
finally:
# Close the client socket
client_socket.close()
def stockTradingAlgorithem(self):
if self.dtRepeatAlgorithemVariable.get() == 0:
repeatNumber = 10
else:
repeatNumber = 1
for i in range(repeatNumber):
# define object atributers
settings = self.dtTickerEntryBox.get(), int(self.dtResultSizeSlider.get()), int(
self.dtDataSizeSlider.get()), self.dtDurationBox.get(), "Ticker"
print(settings)
print(settings[0])
# clear graph
self.plot.cla()
# send request
averageResult, tickerData = self.serverRequest(self, settings)
if tk.get_appearance_mode() == "Light":
self.plot.plot(averageResult.mean(axis=1), color="black")
else:
self.plot.plot(averageResult.mean(axis=1), color="white")
self.plot.plot(
tickerData["Close"].reset_index(drop=True), color="#2fa572", linewidth=3
)
self.canvas.draw()
App()
def cryptoTradingAlgorithem(self):
if self.ctRepeatAlgorithemVariable.get() == 0:
repeatNumber = 20
else:
repeatNumber = 1
for i in range(repeatNumber):
# define object atributers
settings = self.ctTickerEntryBox.get(), int(self.ctResultSizeSlider.get()), int(
self.ctDataSizeSlider.get()), self.ctDurationBox.get(), "Crypto"
# clear graph
self.plot.cla()
# send request
averageResult, tickerData = self.serverRequest(self, settings)
if tk.get_appearance_mode() == "Light":
self.plot.plot(averageResult.mean(axis=1), color="black")
else:
self.plot.plot(averageResult.mean(axis=1), color="white")
self.plot.plot(
tickerData["Close"].reset_index(drop=True), color="#2fa572", linewidth=3
)
self.canvas.draw()
App()
def autoTradingAlgorithem(self):
while self.marketOpenCheck(datetime.now()) == True:
# define object atributers
settings = self.dtTickerEntryBox.get(), int(self.dtResultSizeSlider.get()), int(
self.dtDataSizeSlider.get()), self.dtDurationBox.get(), "Ticker"
# clear graph
self.plot.cla()
# send request
averageResult, tickerData = self.serverRequest(self, settings)
if tk.get_appearance_mode() == "Light":
self.plot.plot(averageResult.mean(axis=1), color="black")
else:
self.plot.plot(averageResult.mean(axis=1), color="white")
self.plot.plot(
tickerData["Close"].reset_index(drop=True), color="#2fa572", linewidth=3
)
self.canvas.draw()
App()
if __name__ == "__main__":
app = App()
app.mainloop()
原来我的系统管理员只阻止了 exe 在文档中运行,所以它在下载中运行良好。