使用cx_Freeze

时间:2019-02-24 14:51:07

标签: python-3.x pyinstaller cx-freeze praw

我试图从我的python脚本制作一个exe文件,当我运行cx_Freeze创建的exe时,出现以下错误,

Traceback (most recent call last):
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Scripts\ScheduleThread.py", line 28, in run
    schedule.run_pending()
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\schedule\__init__.py", line 563, in run_pending
    default_scheduler.run_pending()
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\schedule\__init__.py", line 94, in run_pending
    self._run_job(job)
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\schedule\__init__.py", line 147, in _run_job
    ret = job.run()
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\schedule\__init__.py", line 466, in run
    ret = self.job_func()
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Scripts\MainUpdater.py", line 14, in MainUpdater
    Scrapper(dir_path, subreddit_name)
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Scripts\Scrapper.py", line 2, in Scrapper
    import praw
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\praw\__init__.py", line 14, in <module>
    from .reddit import Reddit  # NOQA
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\praw\reddit.py", line 11, in <module>
    from prawcore import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\prawcore\__init__.py", line 4, in <module>
    from .auth import (Authorizer, DeviceIDAuthorizer, ReadOnlyAuthorizer,  # NOQA
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\prawcore\auth.py", line 5, in <module>
    from requests import Request
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Wallpaper-Updater_venv\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
    from .packages.six.moves import queue
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Scripts\build\exe.win-amd64-3.7\lib\urllib3\packages\six.py", line 92, in __get__
    result = self._resolve()
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Scripts\build\exe.win-amd64-3.7\lib\urllib3\packages\six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "C:\MS_Notes\my_scripts\Wallpaper-Updater\Scripts\build\exe.win-amd64-3.7\lib\urllib3\packages\six.py", line 82, in _import_module
    __import__(name)
ModuleNotFoundError: No module named 'queue'

这是我的setup.py文件

from cx_Freeze import setup, Executable

base = None
includefiles = ["wallpaper_updater_2XT_icon.ico"]

executables = Executable(
    script="WallpaperUpdater.py",
    base=base,
    icon="wallpaper_updater_2XT_icon.ico"
)

packages = ["idna"]
options = {
    'build_exe':
    {
        'packages': packages,
        'include_files': includefiles
    },
}

setup(
    name="Wallpaper Updater",
    options=options,
    version="0.1",
    description='Downloads top images form subreddits and change wallpaper',
    executables=[executables]
)

我也尝试过使用pyinstaller,但是praw出现问题,出现以下错误,

Traceback (most recent call last):
  File "Scripts\ScheduleThread.py", line 28, in run
  File "site-packages\schedule\__init__.py", line 563, in run_pending
  File "site-packages\schedule\__init__.py", line 94, in run_pending
  File "site-packages\schedule\__init__.py", line 147, in _run_job
  File "site-packages\schedule\__init__.py", line 466, in run
  File "Scripts\MainUpdater.py", line 14, in MainUpdater
  File "Scripts\Scrapper.py", line 8, in Scrapper
  File "Scripts\RefreshTokenGen.py", line 75, in RefreshToken
  File "Scripts\RefreshTokenGen.py", line 49, in main
  File "site-packages\praw\reddit.py", line 129, in __init__
  File "site-packages\praw\config.py", line 72, in __init__
  File "site-packages\praw\config.py", line 98, in _initialize_attributes
  File "site-packages\praw\config.py", line 31, in _config_boolean
AttributeError: '_NotSet' object has no attribute 'lower'

显然,这是因为pyinstaller无法将.py完美地制作为.exe,而可以通过更改praw脚本来将其固定。我不确定作为回答here的人该怎么做。没有提到该怎么做,但是我已经联系了他。

如果有人可以帮助我,我将不胜感激。预先谢谢你。

0 个答案:

没有答案