Python 3 cx_Freeze 5.0.2导入错误:没有名为'idna'的模块

时间:2017-08-21 13:23:57

标签: python importerror cx-freeze python-module

我试图使用this site中的setup.py脚本将我的.py脚本转换为可执行文件。由于错误说明,尝试未成功:

ImportError: No module named 'idna'

这是setup.py脚本:

from cx_Freeze import setup, Executable
import sys

base = None

if sys.platform == 'win32':
    base = None


executables = [Executable("my first prog.py", base=base)]

packages = ["idna"]
options = {
    'build_exe': {

        'packages':packages,
    },

}

setup(
    name = "<any name>",
    options = options,
    version = "<any number>",
    description = '<any description>',
    executables = executables
)

以下是错误行:

Traceback (most recent call last):
File "setup.py", line 26, in <module>
  executables = executables
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
  distutils.core.setup(**attrs)
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\distutils\core.py", line 148, in setup
  dist.run_commands()
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 955, in run_commands
  self.run_command(cmd)
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
  cmd_obj.run()
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\distutils\command\build.py", line 135, in run
  self.run_command(cmd_name)
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\distutils\cmd.py", line 313, in run_command
  self.distribution.run_command(command)
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
  cmd_obj.run()
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 219, in run
  freezer.Freeze()
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 621, in Freeze
  self.finder = self._GetModuleFinder()
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 340, in _GetModuleFinder
  finder.IncludePackage(name)
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 653, in IncludePackage
  module = self._ImportModule(name, deferredImports)
File "C:\Users\rayxu\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 350, in _ImportModule
  raise ImportError("No module named %r" % name)
ImportError: No module named 'idna'

关于什么是错的任何想法?我在我的电脑上运行python 3.6.2。

0 个答案:

没有答案