2016-03-18 22 views
0

最近、私はGithubでたくさん使用したプログラムのコードを発見しました。最近Python構文を学んだので、Pythonを練習し、使用するのがより容易になり、より使いやすくなります。Tixを使用するPythonコードから.exeファイルを生成する

フィーチャを実装した後、py2exeを使用して.exeファイルを生成しようとしましたが、Tixモジュールが見つからなかったために機能しませんでした。 Tix.pyを自分の作業ディレクトリにコピーしようとしましたが、これもうまくいきませんでした。その後

私は私が間違って渡す引数はsetup.pyファイルにpy2exeに何かをやっていた、そしてそれがより使いやすく見えたと思っているので、私は、アウトPyInstallerを試してみることにしました。しかし、それは同じ理由からpy2exeの設定ではないということを意味しているため、うまくいきませんでした。

C:\Users\Afonso\Documents\Side Projects\PikaSav>PyInstaller --onefile pikasav.py 
1421 INFO: PyInstaller: 3.1.1 
1421 INFO: Python: 2.7.11 
1421 INFO: Platform: Windows-10-10.0.10240 
1421 INFO: wrote C:\Users\Afonso\Documents\Side Projects\PikaSav\pikasav.spec 
1421 INFO: UPX is not available. 
1437 INFO: Extending PYTHONPATH with paths 
['C:\\Users\\Afonso\\Documents\\Side Projects\\PikaSav', 
'C:\\Users\\Afonso\\Documents\\Side Projects\\PikaSav'] 
1437 INFO: checking Analysis 
1437 INFO: Building Analysis because out00-Analysis.toc is non existent 
1437 INFO: Initializing module dependency graph... 
1452 INFO: Initializing module graph hooks... 
1530 INFO: running Analysis out00-Analysis.toc 
1657 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable 
    required by C:\Python27\python.exe 
1780 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_60a5df56e60dc5df.manifest 
1796 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 
1796 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9158_none_f47f259ef656232a.manifest 
1873 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9158_none ... 
1873 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9158_none_5091b51ebcb97cdc.manifest 
1889 INFO: Searching for file msvcr90.dll 
1889 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9158_none_5091b51ebcb97cdc\msvcr90.dll 
1889 INFO: Searching for file msvcp90.dll 
1889 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9158_none_5091b51ebcb97cdc\msvcp90.dll 
1889 INFO: Searching for file msvcm90.dll 
1889 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9158_none_5091b51ebcb97cdc\msvcm90.dll 
1967 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_60a5df56e60dc5df.manifest 
1967 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 
1967 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9158_none_f47f259ef656232a.manifest 
1967 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9158) 
2514 INFO: Analyzing C:\Users\Afonso\Documents\Side Projects\PikaSav\pikasav.py 
4889 INFO: Looking for import hooks ... 
4905 INFO: Processing hook hook-_tkinter.py 
5077 INFO: checking Tree 
5077 INFO: Building Tree because out00-Tree.toc is non existent 
5092 INFO: Building Tree out00-Tree.toc 
5338 INFO: checking Tree 
5338 INFO: Building Tree because out01-Tree.toc is non existent 
5339 INFO: Building Tree out01-Tree.toc 
5389 INFO: Processing hook hook-encodings.py 
7202 INFO: Looking for ctypes DLLs 
7202 INFO: Analyzing run-time hooks ... 
7202 INFO: Including run-time hook 'pyi_rth__tkinter.py' 
7217 INFO: Looking for dynamic libraries 
7530 INFO: Looking for eggs 
7530 INFO: Using Python library C:\WINDOWS\system32\python27.dll 
7530 INFO: Found binding redirects: 
[BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 9158), publicKeyToken=u'1fc8b3b9a1e18e3b')] 
7546 INFO: Warnings written to C:\Users\Afonso\Documents\Side Projects\PikaSav\build\pikasav\warnpikasav.txt 
7827 INFO: checking PYZ 
7827 INFO: Building PYZ because out00-PYZ.toc is non existent 
7827 INFO: Building PYZ (ZlibArchive) C:\Users\Afonso\Documents\Side Projects\PikaSav\build\pikasav\out00-PYZ.pyz 
8062 INFO: checking PKG 
8062 INFO: Building PKG because out00-PKG.toc is non existent 
8062 INFO: Building PKG (CArchive) out00-PKG.pkg 
8280 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9158) 
16608 INFO: Bootloader C:\Python27\lib\site-packages\pyinstaller-3.1.1-py2.7.egg\PyInstaller\bootloader\Windows-32bit\run.exe 
16608 INFO: checking EXE 
16608 INFO: Building EXE because out00-EXE.toc is non existent 
16608 INFO: Building EXE from out00-EXE.toc 
16702 INFO: Appending archive to EXE C:\Users\Afonso\Documents\Side Projects\PikaSav\dist\pikasav.exe 

そして、ここでは上記の出力に記載されているwarnpikasav.txtコンテンツは、です:私はそれが有用であろうとは思わないが、ここで

は、pyInstallerの出力です。

missing module named unicodedata.ucd_3_2_0 - imported by unicodedata, stringprep, encodings.idna 
missing module named _sre.MAXREPEAT - imported by _sre, sre_constants 
missing module named _warnings.warn_explicit - imported by _warnings, warnings 
missing module named _warnings.filters - imported by _warnings, warnings 
missing module named _warnings.once_registry - imported by _warnings, warnings 
missing module named _warnings.default_action - imported by _warnings, warnings 
missing module named _warnings.warn - imported by _warnings, warnings 
missing module named strop.whitespace - imported by strop, string 
missing module named strop.maketrans - imported by strop, string 
missing module named strop.lowercase - imported by strop, string 
missing module named strop.uppercase - imported by strop, string 
missing module named itertools.islice - imported by itertools, repr, heapq 
missing module named itertools.starmap - imported by itertools, collections 
missing module named itertools.repeat - imported by itertools, collections 
missing module named itertools.imap - imported by itertools, heapq, collections 
missing module named itertools.tee - imported by itertools, heapq 
missing module named itertools.izip - imported by itertools, heapq 
missing module named itertools.count - imported by itertools, heapq, threading 
missing module named itertools.chain - imported by itertools, tokenize, heapq, collections 
missing module named org.PyStringMap - imported by org, copy 
missing module named org - imported by copy 
missing module named exceptions.ReferenceError - imported by exceptions, weakref 
missing module named _weakref.ref - imported by _weakref, _weakrefset, weakref 
missing module named _weakref.ReferenceType - imported by _weakref, weakref 
missing module named _weakref.proxy - imported by _weakref, weakref 
missing module named _weakref.getweakrefs - imported by _weakref, weakref 
missing module named _weakref.getweakrefcount - imported by _weakref, weakref 
missing module named _weakref.ProxyType - imported by _weakref, weakref 
missing module named _weakref.CallableProxyType - imported by _weakref, weakref 
missing module named copy.deepcopy - imported by copy, weakref 
missing module named re._compile - imported by re, sre 
missing module named re.__all__ - imported by re, sre 
missing module named codecs.mbcs_encode - imported by codecs, encodings.mbcs 
missing module named codecs.mbcs_decode - imported by codecs, encodings.mbcs 
missing module named binascii.b2a_qp - imported by binascii, quopri 
missing module named binascii.a2b_qp - imported by binascii, quopri 
missing module named binascii.a2b_uu - imported by binascii, encodings.uu_codec 
missing module named binascii.b2a_uu - imported by binascii, encodings.uu_codec 
missing module named binascii.hexlify - imported by binascii, random 
missing module named errno.EINVAL - imported by errno, StringIO 
missing module named errno.ENOENT - imported by errno, gettext 
missing module named cStringIO.StringIO - imported by cStringIO, gettext, pprint, shlex, tempfile, pickle, encodings.uu_codec, quopri, encodings.quopri_codec 
missing module named struct.calcsize - imported by struct, ctypes 
missing module named _struct.__doc__ - imported by _struct, struct 
missing module named _struct._clearcache - imported by _struct, struct 
missing module named _subprocess.STD_OUTPUT_HANDLE - imported by _subprocess, subprocess 
missing module named _subprocess.CREATE_NEW_PROCESS_GROUP - imported by _subprocess, subprocess 
missing module named _subprocess.STD_INPUT_HANDLE - imported by _subprocess, subprocess 
missing module named _subprocess.STARTF_USESHOWWINDOW - imported by _subprocess, subprocess 
missing module named _subprocess.CREATE_NEW_CONSOLE - imported by _subprocess, subprocess 
missing module named _subprocess.STD_ERROR_HANDLE - imported by _subprocess, subprocess 
missing module named _subprocess.STARTF_USESTDHANDLES - imported by _subprocess, subprocess 
missing module named _subprocess.SW_HIDE - imported by _subprocess, subprocess 
missing module named collections.namedtuple - imported by collections, inspect, unittest.util, difflib, doctest 
missing module named cPickle.loads - imported by cPickle, collections 
missing module named cPickle.dumps - imported by cPickle, collections 
missing module named thread.get_ident - imported by thread, collections 
missing module named thread._local - imported by thread, threading 
missing module named thread.stack_size - imported by thread, threading 
missing module named thread.allocate_lock - imported by thread, _strptime 
missing module named collections.deque - imported by collections, shlex, threading 
missing module named collections.OrderedDict - imported by collections, unittest.util 
missing module named operator.itemgetter - imported by operator, collections, heapq 
missing module named operator.eq - imported by operator, collections 
missing module named operator.attrgetter - imported by operator, inspect 
missing module named _collections.deque - imported by _collections, collections 
missing module named _collections.defaultdict - imported by _collections, collections 
missing module named time.time - imported by time, threading 
missing module named time.sleep - imported by time, threading 
missing module named datetime.date - imported by datetime, _strptime 
missing module named _functools.partial - imported by _functools, functools 
missing module named _functools.reduce - imported by _functools, functools 
missing module named _hashlib.pbkdf2_hmac - imported by _hashlib, hashlib 
missing module named math.sin - imported by math, random 
missing module named math.sqrt - imported by math, random 
missing module named math.cos - imported by math, random 
missing module named math.acos - imported by math, random 
missing module named math.ceil - imported by math, random 
missing module named math.exp - imported by math, random 
missing module named math.log - imported by math, random 
missing module named math.e - imported by math, random 
missing module named math.pi - imported by math, random 
missing module named _io.DEFAULT_BUFFER_SIZE - imported by _io, io 
missing module named _io.BytesIO - imported by _io, io 
missing module named _io.open - imported by _io, io 
missing module named _io.BufferedWriter - imported by _io, io 
missing module named _io.FileIO - imported by _io, io 
missing module named _io.BlockingIOError - imported by _io, io 
missing module named _io.IncrementalNewlineDecoder - imported by _io, io 
missing module named _io.BufferedReader - imported by _io, io 
missing module named _io.BufferedRandom - imported by _io, io 
missing module named _io.StringIO - imported by _io, io 
missing module named _io.BufferedRWPair - imported by _io, io 
missing module named _io.TextIOWrapper - imported by _io, io 
missing module named _io.UnsupportedOperation - imported by _io, io 
missing module named readline - imported by cmd, pdb 
missing module named 'org.python'.PyStringMap - imported by 'org.python', pickle 
missing module named 'org.python' - imported by pickle 
missing module named fcntl - imported by tempfile, subprocess 
missing module named threading.RLock - imported by threading, _threading_local 
missing module named threading.current_thread - imported by threading, _threading_local 
missing module named os.urandom - imported by os, random 
missing module named riscosenviron._Environ - imported by riscosenviron, os 
missing module named riscosenviron - imported by os 
missing module named riscospath - imported by os 
missing module named riscos._exit - imported by riscos, os 
missing module named riscos - imported by os 
missing module named ce._exit - imported by ce, os 
missing module named ce - imported by os 
missing module named _emx_link.link - imported by _emx_link, os 
missing module named _emx_link - imported by os 
missing module named os2._exit - imported by os2, os 
missing module named os2 - imported by os 
missing module named nt._isdir - imported by nt, ntpath 
missing module named nt._getfullpathname - imported by nt, ntpath 
missing module named nt._exit - imported by nt, os 
missing module named pwd - imported by posixpath 
missing module named posix._exit - imported by posix, os 
missing module named posix - imported by os 
missing module named resource - imported by posix 
missing module named _ctypes._wstring_at_addr - imported by _ctypes, ctypes 
missing module named _ctypes._string_at_addr - imported by _ctypes, ctypes 
missing module named _ctypes._cast_addr - imported by _ctypes, ctypes 
missing module named _ctypes._memset_addr - imported by _ctypes, ctypes 
missing module named _ctypes._memmove_addr - imported by _ctypes, ctypes 
missing module named _ctypes.get_last_error - imported by _ctypes, ctypes 
missing module named _ctypes.set_last_error - imported by _ctypes, ctypes 
missing module named _ctypes._check_HRESULT - imported by _ctypes, ctypes 
missing module named _ctypes.set_conversion_mode - imported by _ctypes, ctypes 
missing module named _ctypes._pointer_type_cache - imported by _ctypes, ctypes 
missing module named _ctypes.POINTER - imported by _ctypes, ctypes 
missing module named _ctypes._SimpleCData - imported by _ctypes, ctypes 
missing module named _ctypes.get_errno - imported by _ctypes, ctypes 
missing module named _ctypes.set_errno - imported by _ctypes, ctypes 
missing module named _ctypes.alignment - imported by _ctypes, ctypes 
missing module named _ctypes.addressof - imported by _ctypes, ctypes 
missing module named _ctypes.resize - imported by _ctypes, ctypes 
missing module named _ctypes.byref - imported by _ctypes, ctypes 
missing module named _ctypes.sizeof - imported by _ctypes, ctypes 
missing module named _ctypes.dlopen - imported by _ctypes, ctypes 
missing module named _ctypes.FUNCFLAG_STDCALL - imported by _ctypes, ctypes 
missing module named _ctypes.LoadLibrary - imported by _ctypes, ctypes 
missing module named _ctypes.FUNCFLAG_USE_ERRNO - imported by _ctypes, ctypes 
missing module named _ctypes.FUNCFLAG_USE_LASTERROR - imported by _ctypes, ctypes 
missing module named _ctypes.FUNCFLAG_PYTHONAPI - imported by _ctypes, ctypes 
missing module named _ctypes.FUNCFLAG_CDECL - imported by _ctypes, ctypes 
missing module named _ctypes.FormatError - imported by _ctypes, ctypes 
missing module named _ctypes.ArgumentError - imported by _ctypes, ctypes 
missing module named _ctypes.RTLD_LOCAL - imported by _ctypes, ctypes 
missing module named _ctypes.RTLD_GLOBAL - imported by _ctypes, ctypes 
missing module named _ctypes.__version__ - imported by _ctypes, ctypes 
missing module named _ctypes.CFuncPtr - imported by _ctypes, ctypes 
missing module named _ctypes._Pointer - imported by _ctypes, ctypes 
missing module named _ctypes.Structure - imported by _ctypes, ctypes 
missing module named _ctypes.Array - imported by _ctypes, ctypes 
missing module named _ctypes.Union - imported by _ctypes, ctypes 

Tixは、少なくとも私が見つけたものではありません。私は私の検索から、Tixは幾分古くなっていることを知っていますが、それはプログラムが使用するものであり、作者が元々そうしたので変更したくありませんでした。彼はまた、プログラムのための.exeファイルを生成することもできたので、それが可能であることを意味するだけでなく、おそらくここで何か間違っていると思います。

ありがとうございます。

+0

の 'py2exe' setup.pyパッケージをインクルードするpy2exeオプションを宣言しましたか? – Busturdust

答えて

0

で使う一般的なsetup.pyですさて、私は答えを見つけたようです。私のpythonディレクトリと生成されたファイルのファイルを比較した後、py2exeが何らかの理由でTixからファイルをコピーしていないということがわかりました。

のページをもう一度見つけて、例とは別のTixバージョンがあることに気づき、スクリプトをバージョンに合わせて変更して、完全に動作させるようにしました。ここで

はスクリプトです:

import glob 
import os 
import sys 
from distutils.core import setup 
import py2exe 

def files(folder): 
    for path in glob.glob(folder+'/*'): 
     if os.path.isfile(path): 
      yield path 

data_files=[ 
      ('.', glob.glob(sys.prefix+'/DLLs/tix84*.dll')), 
      ('tcl/tix8.4.3', files(sys.prefix+'/tcl/tix8.4.3/')), 
      ('tcl/tix8.4.3/bitmaps', files(sys.prefix+'/tcl/tix8.4.3/bitmaps/')), 
      ('tcl/tix8.4.3/pref', files(sys.prefix+'/tcl/tix8.4.3/pref/')), 
      ] 

setup(
     script_args=['py2exe'], 
     windows=['pikasav.py'], 
     data_files=data_files, 
    ) 

あなたが将来的にこの問題に遭遇し、異なるTixのバージョンを持っている、ちょうど必要に応じてそれを変更することを忘れないために起こる場合。今、私は可能な最小限のファイル数にする方法を見つけ出す必要がありますが、それはまったく別の話です。

0

これは私がPy2EXE

from distutils.core import setup 
import os 
import shutil 
import py2exe 

data_files = [] 
setup(
    name='ApplicationName', 
    console=['Application.py'], # 'windows' means it's a GUI, 'console' It's a console program, 'service' a Windows' service, 'com_server' is for a COM server 
    # You can add more and py2exe will compile them separately. 
    options={ # This is the list of options each module has, for example py2exe, but for example, PyQt or django could also contain specific options 
     'py2exe': { 
      'packages': [], 
      'dist_dir': 'dist', # The output folder 
      'compressed': True, # If you want the program to be compressed to be as small as possible 
      'includes': ['tix', 'os', 'logging', 'yaml', 'sqlalchemy', 'pymysql'], # All the modules you need to be included, This is where you put the package that is failing to be founhd. so if you import something inside main.py which also imports something, it might break. 
     } 
    }, 

    data_files=data_files # Finally, pass any data files 

) 
+0

私はそれを(自分のコードと一致するように)修正しようとしましたが、まだモジュールを見つけることができません。 – sceptross

関連する問題