.exe python应用无法在未安装python的其他计算机上运行

时间:2020-01-23 19:58:33

标签: python pyinstaller dependency-management

我开发了一个python程序,并使用以下命令将其转换为 .exe 文件:

pyinstaller --onefile master.py

之后,我将其压缩为Zip文件,并使用 NSIS 为该程序进行了安装。然后,我将其上传到了我的Google云端硬盘。

我切换到新计算机(上面没有python)并从云端硬盘下载了程序。我将其安装在计算机上并尝试运行它。之所以有效,是因为我能够输入一些东西。该程序尚未基于GUI,它要求用户在命令提示符上输入一些内容。用户在输入内容后按Enter键,程序会给我一个错误,例如: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 依赖项??

0 个答案:

没有答案