【问题标题】:No module named 'chardet'没有名为“chardet”的模块
【发布时间】:2018-03-21 15:17:18
【问题描述】:

我使用 cx_Freeze 创建了一个 exe。
构建成功。
然后当我点击exe时,我得到了:-

no module named 'queue'

所以,我研究并添加了这一行:-

from multiprocessing import Queue

现在我得到了:-

no module named 'chardet'. 

这是我得到的完整错误:-

Traceback (most recent call last):
  File "C:\Users\pc\AppData\Local\Programs\Python\Python36-32\lib\site-pac
kages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Users\pc\AppData\Local\Programs\Python\Python36-32\lib\site-pac
kages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "normalapi_2103.py", line 1, in <module>
  File "C:\Users\pc\AppData\Local\Programs\Python\Python36-32\lib\site-pac
kages\requests-2.18.4-py3.6.egg\requests\__init__.py", line 44, in <module>
    import chardet
ModuleNotFoundError: No module named 'chardet'

我没有得到要导入的内容...

我也试过添加

setup.py 中的“requests”和“os”包。

但没有运气......

【问题讨论】:

    标签: python selenium cx-freeze


    【解决方案1】:

    这应该只是将chardet 添加到includes 命令的问题。

    build_exe_options = {"includes":["chardet"]}
    

    查看build_exe 选项。

    【讨论】:

      【解决方案2】:

      有同样的问题。另一个解决方法是将版本降级为chardet==3.0.2。 在将后续记录和元数据文件下载到 chardet 文件夹之前,我什至无法做到这一点:

      https://rabbit.test.polarvagnen.se/env/lib/python3.6/site-packages/chardet-3.0.4.dist-info/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-03-28
        • 2017-12-30
        • 2018-01-06
        • 2018-11-11
        • 2015-04-10
        • 2013-11-27
        • 2014-02-17
        相关资源
        最近更新 更多