Python sys.argv在运行.py文件时工作,但在cx\u冻结后出错

Python sys.argv在运行.py文件时工作,但在cx\u冻结后出错,python,urllib,sys,Python,Urllib,Sys,我有一小段WIP代码 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: p

我有一小段WIP代码

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")
当我从cmd运行此命令时

main.py-r某物

它按预期工作,我得到了输出。然后,我使用这个构建文件对其应用cx\U冻结

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)])
当我尝试运行cmd生成的.exe时,出现以下错误:

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>
C:\Users\Compaq\Documents\Programming\office\build\exe.win32-3.4>main.exe-r sth
某物
回溯(最近一次呼叫最后一次):
文件“C:\Python34\lib\site packages\cx\u Freeze\initscripts\Console.py”,第27行
在里面
执行官(代码、指令)
文件“main.py”,第2行,在
文件“c:\python\32位\3.4\lib\importlib\\u bootstrap.py”,第2214行,在查找a中
钕负载
文件“c:\python\32位\3.4\lib\importlib\\u bootstrap.py”,第2203行,在查找a中
nd_加载_解锁
文件“c:\python\32位\3.4\lib\importlib\\u bootstrap.py”,第1191行,在加载中
锁定
文件“c:\python\32位\3.4\lib\importlib\\u bootstrap.py”,第1161行,在加载b中
ackward_兼容
AttributeError:“模块”对象没有属性“\u fix\u up\u module”
C:\Users\Compaq\Documents\Programming\offit\build\exe.win32-3.4>
这意味着什么?如何解决?似乎是urllib导入行…

读取 及


从安装非官方cx\u freeze必须是cx\u freeze的问题,它与pyinstaller main.py--onefile一起工作。