Python 程序不';在pyinstaller生成exe文件后无法工作

Python 程序不';在pyinstaller生成exe文件后无法工作,python,python-3.x,pyinstaller,sympy,sys,Python,Python 3.x,Pyinstaller,Sympy,Sys,我使用numpy、sympy和sys编写了一个Python程序,在IDE中运行良好。这是代码 import numpy as np from sympy import * import sys f = open("result.txt", 'w+') for line in sys.stdin: f.write(line) f.close() f = open("result.txt", 'r') data = f.read().split(&q

我使用numpy、sympy和sys编写了一个Python程序,在IDE中运行良好。这是代码

import numpy as np
from sympy import *
import sys

f = open("result.txt", 'w+')
for line in sys.stdin:
    f.write(line)
f.close()
f = open("result.txt", 'r')
data = f.read().split("\n")
i = 0
while i < len(data):
    data[i] = data[i].split(' ')
    i += 1
print(data)
amount = int(data[0][0])
print(amount)
matrix = np.zeros((amount, amount))
i = 0
j = 0

while i < amount:
    while j < amount:
        matrix[i, j] = int(data[i + 1][j])
        j += 1
    j = 0
    i += 1
i = 0
j = 0
counter = 0
formula = 1
while i < amount:
    while j < amount:
        if matrix[i, j] == 1:
            x = symbols(str(i + 1))
            y = symbols(str(j + 1))
            if counter == 0:
                formula = (~x | ~y)
                counter += 1
            else:
                formula = formula & (~x | ~y)
        j += 1
    j = 0
    i += 1
formula_to_string = pycode(simplify_logic(formula, form='dnf', force=True))
massive_to_parse = formula_to_string.split("or")
k = 1
i = 0
while i < len(massive_to_parse):
    print("{", end='')
    while k < amount + 1:
        try:
            massive_to_parse[i].index(str(k))
        except ValueError:
            print("V",k, sep='', end='')
        finally:
            k += 1
    print("}-максимальное внутренне устойчивое множество")
    k = 1
    i += 1
但当我启动它时,就会出现这种错误。


我如何解决这个问题?因为我需要exe文件供大学从C上的其他程序启动它,所以我刚刚用numpy+Symphy+pyinstaller创建了一个Anaconda python3环境(并不是说任何环境都是Anaconda特定的),我使用了
pyinstaller--onefile r1.py
(顺便说一句,这里是pyinstaller)。我得到一个240MB的.exe二进制文件,运行正常。@wsdookadr,对不起,你不能用我的代码创建.exe吗?我不明白为什么它对我不起作用…可能是sys库的问题?从stdinWARNING获取数据:未找到隐藏导入“pkg_resources.py2_warn”!17086警告:未找到隐藏的导入“pkg_resources.markers”!这就是我想要的says@wsdookadr,我可以问你你使用什么版本的python吗?也许是因为Python3.9?我用的是Python3.7
pyinstaller main.py