我按照以下指南:https://py2app.readthedocs.io/en/latest/tutorial.html . 我一开始遇到这个错误:

script1:python运行时不能找到(原文如此) . 您可能需要安装Python的框架版本,或者在此应用程序Info.plist文件中编辑PyRuntimeLocations数组 .

所以我根据这些指示改变了我的设置文件:How do I use py2app with Anaconda python?包括:

OPTIONS = {'argv_emulation': True,
       'plist': {
           'PyRuntimeLocations': [
            '@executable_path/../Frameworks/libpython3.6m.dylib',
            '/Users/myname/anaconda3/lib/libpython3.6m.dylib'
           ]
       }}

现在,当我在终端中运行 ./dist/MyApplication.app/Contents/MacOS/MyApplication 时,我得到:

My-MacBook-Pro:script myname$ ./dist/script1.app/Contents/MacOS/script1
Traceback (most recent call last):
  File "/Users/myname/Desktop/script/dist/script1.app/Contents/Resources/__boot__.py", line 420, in <module>
    _run()
  File "/Users/myname/Desktop/script/dist/script1.app/Contents/Resources/__boot__.py", line 414, in _run
    exec(compile(source, script, 'exec'), globals(), globals())
  File "/Users/myname/Desktop/script/script1.py", line 10, in <module>
    from tkinter import *
  File "/Users/myname/anaconda3/lib/python3.6/tkinter/__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
2018-01-29 13:56:56.818 script1[8020:593713] script1 Error

我是否必须安装Tcl / Tk,或者Tk-devel?我发现这个Tkinter: "Python may not be configured for Tk",看起来我可能需要重建Python .

我正在尝试进入应用程序的脚本是这样的:

# coding: utf-8

# In[1]:


import os
import shutil
import csv
from tkinter import *
from tkinter.filedialog import *
from tkinter import ttk


def ask_for_file(event):
    global find_file
    find_file = askopenfilename()


def ask_for_folder(event):
    global find_folder
    find_folder = askdirectory()


def make_folders(event):
    name_list = []
    with open(find_file) as names_csv:
        readCSV = csv.reader(names_csv)
        big_list = list(readCSV)
        for sublist in big_list:
            for item in sublist:
                name_list.append(item)

    for i in name_list:
        # make folders for all names
        current_directory = os.getcwd()
        final_directory = os.path.join(current_directory, 'Kandidater', i)
        if not os.path.exists(final_directory):
            os.makedirs(final_directory)
        s# copy files to folders
        source_files = os.listdir(find_folder)
        for file_name in source_files:
            full_file_name = os.path.join(find_folder, file_name)
            if (os.path.isfile(full_file_name)):
                shutil.copy(full_file_name, final_directory)

root = Tk()

root.title("Kandidatmapper")

Button_1 = ttk.Button(root, text="Vælg liste over kandidater")
Button_2 = ttk.Button(root, text="Vælg mappe med filer der skal i mapperne")
Button_3 = ttk.Button(root, text="Lav kandidatmapper")

Button_1.pack()
Button_2.pack()
Button_3.pack()

Button_1.bind("<Button-1>", ask_for_file)
Button_2.bind("<Button-1>", ask_for_folder)
Button_3.bind("<Button-1>", make_folders)

root.mainloop()

我的python版本是3.6.2与anaconda,但写 pythonpython3 我得到不同的输出:

$ python
Python 3.6.2 |Anaconda custom (x86_64)| (default, Sep 21 2017, 18:29:43) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

$ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

有人可以帮忙吗?