2014-09-30 1 views
2

Python 프로젝트 용 설치 프로그램을 어떻게 만들 수 있는지 검색했습니다. py2exe 모듈이라는 좋은 대안을 찾았습니다. 이것은 setup.py에서 사용됩니다.Python : py2exe를 사용하는 설치 프로그램과 OpenOPC 모듈을 사용하는 프로젝트

그러나 내 프로젝트는 OpenOPC 모듈에 win32com 모듈이있는 com 서버를 사용합니다.

IOError: [Errno 2] No such file or directory: 
'C:\\Users\\(project directory)\\dist\\lib\\shared.zip\\win32com\\gen_py\\__init__.py' 

내가 이것에 대해 더 많은 검색이 페이지 발견 : http://www.py2exe.org/index.cgi/Py2exeAndWin32com

이를 내가 exe 파일과 독립 directorie를 생성 한 후 이러한 이유로 은이 실행이 예외를 반환하지 작업을 수행 페이지는 setup.py가 com 서버를 모듈로 포함하는 '모델'을 가르친다. 하지만이 '모델'을 이해하지 못했습니다. 모든 com 서버에서 일반적이며 OpenOPC 모듈을 어디에 포함시켜야하는지 소개하지 않습니다.

from distutils.core import setup 
import py2exe 
import sys 

class Target: 
    def __init__(self): 
     self.version = version 
     self.company_name = author 
     self.copyright = license_ 
     self.name = name 
     self.description = description 
     self.modules = ['C:\\OpenOPC\\src\\OpenOPC.py'] 
     self.create_exe = True 
     self.create_dll = False 


sys.argv.append('py2exe') 
setup(name=name, 
     version=version, 
     author=author, 
     author_email=author_email, 
     maintainer=maintainer, 
     maintainer_email=maintainer_email, 
     url=url, 
     license=license_, 
     description=description, 
     long_description=long_description, 
     keywords=keywords, 
     platforms=platforms, 
     console=console, zipfile=zipfile, 
     com_server=[Target()]) 

불행하게도이 작동하지 않았다 내가 좋아하는이 모델을 사용하는 몇 가지 방법을 시도했습니다. 모듈에 다른 파일이나 디렉토리를 Target 클래스 생성자에 넣으려고했습니다. 다른 점이 없다면 OpenOPC 모듈을 여기에 넣어야합니다.

+0

"작동하지 않았다"에 대해 자세히 설명해 주실 수 있습니까? 이 예제를 사용할 때 다른 오류가 발생합니까? 나는 내가 배포 한 스크립트에서 COM을 사용했다는 것을 확신합니다 - 내가 게시 할 수있는 예제를 찾을 수 있어야합니다. –

+0

이 예제를 사용한 마지막 오류는 단순히 모듈을 찾지 못했습니다. 그게 다야. 그리고 C 디스크의 OpenOPC 디렉토리에서 다른 파일과 지시어를 넣으려고했습니다. –

+0

나는이 사람처럼 노력했고 일했다 : https://stackoverflow.com/questions/9002097/ignoring-library-zip-in-py2exe –

답변

0

은 내가 그랬어 : 그것은

options = {'py2exe': {'packages': ['win32com']}} 

sys.argv.append('py2exe') 
setup(name=name, 
     version=version, 
     author=author, 
     author_email=author_email, 
     maintainer=maintainer, 
     maintainer_email=maintainer_email, 
     url=url, 
     license=license_, 
     description=description, 
     long_description=long_description, 
     keywords=keywords, 
     platforms=platforms, 
     console=console, zipfile=zipfile, 
     options=options) 

입니다 곳. 일했다. 그리고 내 응용 프로그램에는 OPC 클라이언트가 있으며 OPC 서버는 없습니다. OPC 서버 (COM 서버)가 있다면 아마도 더 어려울 것입니다.

관련 문제