gpt4 book ai didi

python - Py2exe 添加包(例如 Carbon)到 exe

转载 作者:太空宇宙 更新时间:2023-11-04 05:14:29 25 4
gpt4 key购买 nike

我在使用这个导入的地方创建了一个脚本:

import MySQLdb
import sys
import paramiko as pm
import os

现在我尝试使用 py2exe 和这个 setup.py 将这个脚本转换为 .exe:

# setup.py 
from distutils.core import setup
import os
import MySQLdb
import sys
import paramiko
import py2exe

data_files = []
setup(
name='Worker',
console=['Script.py'],
options={
'py2exe': {
'packages': [],
'dist_dir': 'dist',
'compressed': True,
'includes': ['paramiko', 'MySQLdb'],
}
},

data_files=data_files

)

如果我运行安装程序,来自日志的一部分:

The following modules appear to be missing
['Carbon', 'Carbon.Files', '_imp', '_scproxy', '_sysconfigdata', '_thread', 'builtins', 'cryptography.hazmat.bindings._commoncrypto', 'gssapi', 'importlib.machinery', 'pkg_resources.extern.appdirs', '
pkg_resources.extern.packaging', 'pkg_resources.extern.six', 'pkg_resources.extern.six.moves', 'sspi', 'sspicon', 'win32pipe', 'winreg']

*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.

它创建一个 exe,但如果我尝试运行它,我会收到模块丢失的错误。那么如何将这些模块添加到我的 exe/setup.py 中呢?

最佳答案

尝试运行这段代码:

setup.py

from distutils.core import setup
import os
import MySQLdb
import sys
import paramiko
import py2exe

data_files = []
setup(
name='Worker',
console=['Script.py'],
options={
'py2exe': {
'packages': ['Carbon', 'Carbon.Files', '_imp', '_scproxy', '_sysconfigdata', '_thread', 'builtins', 'cryptography.hazmat.bindings._commoncrypto', 'gssapi', 'importlib.machinery', 'pkg_resources.extern.appdirs', ' pkg_resources.extern.packaging', 'pkg_resources.extern.six', 'pkg_resources.extern.six.moves', 'sspi', 'sspicon', 'win32pipe', 'winreg'],
'dist_dir': 'dist',
'compressed': True,
'includes': ['paramiko', 'MySQLdb'],
}
},

data_files=data_files

)

我引用了这个Answer .

关于python - Py2exe 添加包(例如 Carbon)到 exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42131380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com