我正在使用pyinstaller
将Python脚本转换为.exe文件。然后在Flask中使用send_file()
,我将它发送给客户端。我收到一个错误:
IOError:[Errno 22]无效模式('rb')或文件名:'C:\ Users \ Dell \ Desktop \ mummy \ dist \ tc.exe'
这里tc.exe
是我想发送的可执行文件,它位于dist文件夹中。
此代码不会给出任何错误,并使用send_file发送:
import subprocess
print ("hi")
subprocess.call('ipconfig > zzz.txt', shell = True)
x = raw_input()
但我的代码(它检查系统是否安装了python)给出错误:
import sys
import subprocess
subprocess.call('python -V 2> z1.txt' , shell = True)
var1 = subprocess.call('find /i "not recognized" z1.txt', shell = True)
subprocess.call('del z1.txt' , shell = True)
if(var1 == 0):
print ("python not found")
else:
print ("python found")
x=raw_input()
(它在cmd提示符中调用python版本并将其存储在文本文件中。然后它检查文本文件中是否存在“not found”关键字。如果存在,则表示未安装python)
为屏幕提供raw_input()等待我看输出。
发送一个文件时我收到错误的两个文件有什么区别?
\ t被视为制表符。将文件的名称从tc更改为不以t开头的其他内容,它将正常工作。