2014-07-17 7 views
0

그래서이 작은 조각의 WIP 코드가 있습니다.Python sys.argv는 .py 파일을 실행할 때 작동하지만 cx_Freeze 이후 오류

import sys 
import urllib 


def download(url,file_name): 
    urllib.request.urlretrieve(url,file_name) 

if "-r" in sys.argv[1:]: 
    print("Do this") 
    print("gave: "+sys.argv[2]) 
if sys.argv[3]: 
    print("and: "+sys.argv[3]) 
else: 
    print("some message") 

나는 그것은 예상대로, 내가 출력을 얻을 작동

main.py -r sth sth

에 cmd를에서이 프로그램을 실행할 때. 내가 cmd를에서 생산 한 .exe를 실행하려고하면 나는 다음이 빌드 파일

import sys 
from cx_Freeze import setup, Executable 

# Dependencies are automatically detected, but it might need fine tuning. 
build_exe_options = {"packages": ["os"]} 

# GUI applications require a different base on Windows (the default is for a 
# console application). 
base = None 


setup( name = "offit", 
     version = "0.1", 
     description = "offit package and dependencie management", 
     options = {"build_exe": build_exe_options}, 
     executables = [Executable("main.py", base=base)]) 

를 사용하여, 그것을 나 cx_Freeze을 적용,이 오류가 얻을 :

C:\Users\Compaq\Documents\Programming\offit\build\exe.win32-3.4>main.exe -r sth 
sth 
Traceback (most recent call last): 
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27 
, in <module> 
exec(code, m.__dict__) 
File "main.py", line 2, in <module> 
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_a 
nd_load 
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_a 
nd_load_unlocked 
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u 
nlocked 
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b 
ackward_compatible 
AttributeError: 'module' object has no attribute '_fix_up_module' 

C:\Users\Compaq\Documents\Programming\offit\build\exe.win32-3.4> 

을이 평균 그것을 해결하기 위해 수있는 방법은 무엇 ? 이 pyInstaller 중에의 main.py와 함께 작동,

+0

에서 비 상용 나 cx_Freeze를 설치 읽어 .... URLLIB 가져 오기 선 것 같다 - -onefile. – dev247

답변