Python 使用PyInstaller创建EXE:EXE工作不正常/未导入多个模块

Python 使用PyInstaller创建EXE:EXE工作不正常/未导入多个模块,python,selenium,import,pyinstaller,Python,Selenium,Import,Pyinstaller,我的python脚本应该导入以下内容: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions im

我的python脚本应该导入以下内容:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import *
from selenium.webdriver.common.keys import Keys
from random import uniform
from xlutils.copy import copy
import xlrd
import wx
import os
import shutil
import time
from threading import *
当我使用Pyinstaller创建EXE时,EXE不能正常工作。python脚本运行良好

这似乎是因为Pyinstaller没有包含一些模块。生成的警告文件表示未导入以下内容:

W: no module named xlrd.XL_CELL_EMPTY (top-level import by xlutils.margins)  
W: no module named pwd (top-level import by tarfile)  
W: no module named xlrd.XL_CELL_TEXT (top-level import by xlutils.margins)  
W: no module named readline (delayed import by pdb)  
W: no module named xlrd.XL_CELL_NUMBER (top-level import by xlutils.margins)  
W: no module named xlrd.open_workbook (top-level import by xlutils.margins)  
W: no module named _scproxy (conditional import by urllib)  
W: no module named _sysconfigdata (delayed import by distutils.sysconfig)  
W: no module named pwd (delayed import by getpass)  
W: no module named errorhandler (delayed import by xlutils.filter)  
W: no module named EasyDialogs (conditional import by getpass)  
W: no module named termios (top-level import by getpass)  
W: no module named grp (top-level import by tarfile)  
W: no module named xml.dom.XML_NAMESPACE (delayed import by xml.dom.pulldom)  
W: no module named gestalt (delayed import by platform)  
W: no module named org (top-level import by copy)  
W: no module named xlrd.XL_CELL_BLANK (top-level import by xlutils.margins)  
W: no module named fcntl (top-level import by tempfile)  
W: no module named xml.dom.EMPTY_PREFIX (top-level import by xml.dom.minidom)  
W: no module named http (top-level import by selenium.selenium)  
W: no module named readline (delayed, conditional import by cmd)  
W: no module named elementtree (delayed, conditional import by xlrd.xlsx)  
W: no module named xlrd.open_workbook (conditional import by xlutils.margins)  
W: no module named java (delayed import by platform)  
W: no module named cl (delayed import by aifc)  
W: no module named posix (conditional import by __main__)  
W: no module named xmlparse (top-level import by pyexpat)  
W: no module named posix (conditional import by pyi_os_path)  
W: no module named java (conditional import by xml.sax._exceptions)  
W: no module named lxml (delayed, conditional import by xlrd.xlsx)  
W: no module named ElementC14N (top-level import by xml.etree.ElementTree)  
W: no module named xlrd.XL_CELL_TEXT (conditional import by xlutils.margins)  
W: no module named _emx_link (conditional import by os)  
W: no module named posix (conditional import by os)  
W: no module named xml.dom.DOMImplementation (top-level import by xml.dom.domreg)  
W: no module named xmltok (top-level import by pyexpat)  
W: no module named rourl2path (conditional import by urllib)  
W: no module named xlrd.cellname (top-level import by xlutils.margins)  
W: no module named pwd (delayed import by webbrowser)  
W: no module named xml.dom.EMPTY_NAMESPACE (top-level import by xml.dom.expatbuilder)  
W: no module named xml.dom.EMPTY_PREFIX (top-level import by xml.dom.expatbuilder)  
W: no module named http (top-level import by selenium.webdriver.remote.remote_connection)  
W: no module named SOCKS (top-level import by ftplib)  
W: no module named _xmlplus (top-level import by xml)  
W: no module named guppy (top-level import by xlutils.filter)  
W: no module named http (top-level import by   selenium.webdriver.opera.webdriver)`  

这是否意味着正在导入selenium模块?我很难找出exe的错误。

我认为Selenium被视为一个外部模块,因此您需要通过添加一个hooks文件来指定它的路径。
看一看如何用正确的路径设置钩子文件。在“使用外部模块”下查看。

在“hooks”文件夹中已经有一个selenium.py文件(我没有添加)。我认为问题实际上可能是xlrd/xlutils。那篇教程对如何制作钩子有点模糊。这使我看起来好像只需要创建一个名为“hook xlrd.py”的文件并包含以下语句:from PyInstaller.hooks.hookutils import collect_data_files dates=collect_data_files('xlrd'))