【发布时间】:2018-05-25 16:59:46
【问题描述】:
我正在尝试使用 cx_Freeze 创建一个独立的 Python3 macOS 应用程序,包括 tkinter 和 selenium。我的项目中有三个文件:
-
tkinter_tab3.py(包含图形用户界面) -
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)
【问题讨论】:
标签: macos python-3.x selenium tkinter cx-freeze