cx_Freeze 用于创建 macOS 应用程序的编码
cx_Freeze encodings for creating macOS application
我正在尝试使用 cx_Freeze 创建一个独立的 Python3 macOS 应用程序,包括 tkinter 和 selenium。我的项目中有三个文件:
tkinter_tab3.py
(包含 GUI)
user.txt
(包含用户信息)
ver004.py
(从 tkinter_tab3.py
调用并执行任务)
我创建了以下 setup.py
文件,其中 tkinter_tab3.py
是要转换为可执行文件的文件:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ['encodings'], excludes = [])
includefiles = ['user.txt', 'ver004.py']
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('tkinter_tab3.py', base=base, targetName = 'suprbotcho')
]
setup(name='suprbotcho',
version = '1.0',
description = 'test',
options = dict(build_exe = buildOptions),
executables = executables)
但是,当我 运行 $python3 setup.py build
然后单击创建的可执行文件时,我在终端中收到此错误消息:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
此外,当我 运行 $python3 setup.py bdist.mac
和 $python3 setup.py bdist.dmg
时,我收到以下错误:
build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):
error: can't copy 'build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):': doesn't exist or not a regular file
我不明白我哪里出错了,因为我已经阅读了有关 encodings
问题的其他帖子,但是在尝试发布的解决方案后我没有发现任何进展。
以下是每个 python 文件的导入:
tkinter_tab3.py
from tkinter import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from ver004 import SuPrBoTcHo, InIt_UsEr
ver004.py
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
如果我能得到解决这个特定问题的帮助,那就太好了。如果您有任何具体问题,请随时告诉我。
(python 版本: 3.6.3)
我遇到了同样的问题。
解决方案是将 cxfreeze 升级到最新版本,即执行以下步骤-
pip install -U cx_Freeze==6.0.b1
我正在尝试使用 cx_Freeze 创建一个独立的 Python3 macOS 应用程序,包括 tkinter 和 selenium。我的项目中有三个文件:
tkinter_tab3.py
(包含 GUI)user.txt
(包含用户信息)ver004.py
(从tkinter_tab3.py
调用并执行任务)
我创建了以下 setup.py
文件,其中 tkinter_tab3.py
是要转换为可执行文件的文件:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ['encodings'], excludes = [])
includefiles = ['user.txt', 'ver004.py']
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('tkinter_tab3.py', base=base, targetName = 'suprbotcho')
]
setup(name='suprbotcho',
version = '1.0',
description = 'test',
options = dict(build_exe = buildOptions),
executables = executables)
但是,当我 运行 $python3 setup.py build
然后单击创建的可执行文件时,我在终端中收到此错误消息:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
此外,当我 运行 $python3 setup.py bdist.mac
和 $python3 setup.py bdist.dmg
时,我收到以下错误:
build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):
error: can't copy 'build/suprbotcho-1.0.app/Contents/MacOS/lib/numpy/core/lib/libnpymath.a(npy_math.o):': doesn't exist or not a regular file
我不明白我哪里出错了,因为我已经阅读了有关 encodings
问题的其他帖子,但是在尝试发布的解决方案后我没有发现任何进展。
以下是每个 python 文件的导入:
tkinter_tab3.py
from tkinter import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from ver004 import SuPrBoTcHo, InIt_UsEr
ver004.py
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import numpy as np
import time
from datetime import datetime
from threading import Timer
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
如果我能得到解决这个特定问题的帮助,那就太好了。如果您有任何具体问题,请随时告诉我。
(python 版本: 3.6.3)
我遇到了同样的问题。
解决方案是将 cxfreeze 升级到最新版本,即执行以下步骤-
pip install -U cx_Freeze==6.0.b1