问题描述
我想从 python 中的 cx_freeze 模块制作一个 exe 文件。
我的“main_file.py”是将“Data.csv”文件上传到谷歌云,如下所示:
from google.cloud import storage
import os
os.chdir(r"F:\Cloud") # Select working directory
storage_client = storage.Client.from_service_account_json("My First Project-XXXXXXXXXXX.json") # Google Cloud Services (GCS) credentials
bucket = storage_client.get_bucket('My_bucket') # Bucket created in GCS
blob = bucket.blob('Data.csv') # Name of the csv that I want in My_bucket
blob.upload_from_filename('Data.csv') # File that I wish to upload in My_bucket of Google Cloud
代码运行得很好。
现在,为了冻结代码并制作一个exe文件,“setup.py”文件是这样的:
import sys
import cx_Freeze
from cx_Freeze import setup,Executable
import os
import os.path
if (sys.platform == "win32"):
base = "win32gui"
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR,'tcl','tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR,'tk8.6')
includefiles = [(r'C:\Users\USER\AppData\Local\Programs\Python\python37\Lib\site-packages\google')]
setup(name = "Application",options={'build_exe': {'include_files': includefiles}},version = "0.1",description = "",executables = [Executable("main_file.py",base=base)])
当我运行“main_file.exe”时,我收到一条错误消息:“没有名为 email.mime.application 的模块”:
然而,正如我之前提到的,脚本文件“main_file.py”在独立运行时(即没有任何冻结代码)不会出现任何此类错误。
有人可以告诉我我哪里出错了吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)