python - .exe python 应用程序不能在没有安装 python 的其他机器上运行
问题描述
我开发了一个 python 程序并使用以下方法将其转换为.exe文件:
pyinstaller --onefile master.py
之后,我将其压缩为 Zip 文件并使用NSIS为该程序制作了安装程序。然后,我将其上传到我的 Google Drive。
我切换到一台新计算机(上面没有 python)并从 Drive 下载了我的程序。我将它安装在机器上并尝试运行它。它起作用了,因为我能够输入一些东西。这个程序还不是基于 GUI 的,它要求用户在Command Prompt上输入一些东西。一旦用户在输入输入后按下回车,程序就会给我一个错误,例如:ImportError: No module named selenium
import os, time
import threading
status = True
while status:
# number of windows user want
num_of_win = input("How many screen would you like to open?\nNumber of screens [1-10]: ")
try:
# convert it into an int
num_of_win = int(num_of_win)
# if number of windows is greater than 10
if num_of_win > 10:
print("Max number of screens you can have is 10. Please try again.")
# if number of windows is equal to or less than 10
elif num_of_win <= 10:
# brake the loop
status = False
# open cmd windows num_of_win times
for x in range(num_of_win):
# this is path to index.py with parameter
# its parameter is based on how many window we open in this for loop
# /k = cmd stays after terminated
# /c = cmd quits program completely
path = "start cmd.exe /K python index.py " + str(x)
threading.Thread(target=(os.system(path)))
time.sleep(5)
else:
print("Something is wrong, try again!")
# if user enters letters
except ValueError:
print("Please ONLY enter numbers")
我猜当我将它转换为.exe文件时,它没有加载依赖模块。我的问题是,如何让它在没有安装 python 的机器上运行?
注意:master.exe运行另一个 python 文件index.py
难道是当我将master.py转换为.exe时,它只加载写在master.py中的依赖项而忽略index.py依赖项????
解决方案
推荐阅读
- javascript - 自动化表单:表单错误,未捕获的类型错误:无法读取 null 的属性“值”
- git - 如何查看 git commit id
- r - ggplot 绘制每小时股价并没有忽略周末效应
- django - 表单验证 - Django 中的注册和登录错误处理
- javascript - React - 刷新后如何保留页面网址?
- c - 如何从另一个目录安装 GDB?
- c++ - 如何在 C++ 中获取 CPU、内存(等)的 Windows 系统信息
- latex - 如何在包含的代码片段中制作 jekyll 进程`{%` 结构
- session - 在 gsp 中访问会话会引发“提交响应后无法创建会话”错误?
- ubuntu - 设置 Varnish Apache2 HTTP & HTTPS Ubuntu 16.04