2017-12-12 169 views
7

Tôi đang cố gắng tạo một ứng dụng macOS độc lập Python3 bao gồm tkinter và selen bằng cách sử dụng cx_Freeze. Có ba tác phẩm trong dự án của tôi:Mã hóa cx_Freeze để tạo ứng dụng macOS

  • tkinter_tab3.py (chứa GUI)
  • user.txt (chứa thông tin người dùng)
  • ver004.py (gọi từ tkinter_tab3.py và thực hiện nhiệm vụ)

Tôi tạo ra sau setup.py tệp với tkinter_tab3.py là tệp được chuyển thành tệp thi hành:

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) 

Tuy nhiên, khi tôi chạy $python3 setup.py build sau đó nhấn vào thực thi được tạo ra, tôi nhận được lỗi này trở lại trong thiết bị đầu cuối:

Fatal Python error: Py_Initialize: unable to load the file system codec 
ModuleNotFoundError: No module named 'encodings' 

Bên cạnh đó, khi tôi chạy $python3 setup.py bdist.mac$python3 setup.py bdist.dmg, tôi nhận được lỗi sau:

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 

Tôi không hiểu nơi tôi đang sai vì tôi đã đọc các bài đăng khác về sự cố encodings tuy nhiên tôi không tìm thấy tiến bộ nào sau khi thử các giải pháp đã đăng.

Dưới đây là hàng nhập khẩu cho mỗi file 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 

Nếu tôi có thể nhận được sự giúp đỡ về sửa chữa vấn đề cụ thể này, đó sẽ là tuyệt vời. Nếu bạn có bất kỳ câu hỏi cụ thể nào, vui lòng cho tôi biết.

(phiên bản python: 3.6.3)

Trả lời

4

Tôi cũng gặp vấn đề tương tự.

Giải pháp là để nâng cấp cxfreeze lên phiên bản mới nhất, tức là làm steps-

pip install -U cx_Freeze==6.0.b1 
+0

cám ơn sau cho chỉnh sửa @Alexan –

Các vấn đề liên quan