You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

批处理文件执行Python脚本时提示找不到pyexcel模块的问题求助

批处理文件执行Python脚本时提示找不到pyexcel模块的问题求助

我正在尝试写一个批处理文件来启动一个用到openpyxl和pyexcel的Python脚本。Powershell里运行这个脚本没问题,能正常导入两个模块,但批处理里却找不到pyexcel,明明两个模块都在同一个文件夹里。

我已经确认Python脚本本身是能正常运行的,导入两个模块都没问题。

下面是我的批处理代码片段,要是需要更多信息我再补充:

ECHO ON
REM A batch script to execute a python script
SET PATH=%PATH%;C:\User\username\AppData\Roaming\Python\Python313-32\site-packages
python formatter.py
PAUSE

我遇到的错误是:

ModuleNotFoundError: No module named 'pyexcel'

下面是site-packages文件夹的结构:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        02/14/2025     11:09                click
d-----        02/14/2025     11:09                click-8.1.8.dist-info
d-----        02/14/2025     11:09                colorama
d-----        02/14/2025     11:09                colorama-0.4.6.dist-info
d-----        02/14/2025     10:03                et_xmlfile
d-----        02/14/2025     10:03                et_xmlfile-2.0.0.dist-info
d-----        02/14/2025     11:09                lml
d-----        02/14/2025     11:09                lml-0.1.0.dist-info
d-----        02/14/2025     10:03                openpyxl
d-----        02/14/2025     10:03                openpyxl-3.1.5.dist-info
d-----        02/14/2025     11:09                pyexcel
d-----        02/14/2025     11:09                pyexcel-0.7.1.dist-info
d-----        02/14/2025     11:09                pyexcel_cli
d-----        02/14/2025     11:09                pyexcel_cli-0.0.3.dist-info
d-----        02/14/2025     11:09                pyexcel_io
d-----        02/14/2025     11:09                pyexcel_io-0.6.7.dist-info
d-----        02/14/2025     11:09                pyexcel_xls
d-----        02/14/2025     11:09                pyexcel_xls-0.7.0.dist-info
d-----        02/14/2025     11:09                pyexcel_xlsx
d-----        02/14/2025     11:09                pyexcel_xlsx-0.6.0.dist-info
d-----        02/14/2025     11:09                texttable-1.7.0.dist-info
d-----        02/14/2025     11:04                xlrd
d-----        02/14/2025     11:04                xlrd-2.0.1.dist-info
d-----        02/14/2025     11:09                xlwt
d-----        02/14/2025     11:09                xlwt-1.3.0.dist-info
d-----        02/14/2025     11:09                __pycache__
-a----        02/14/2025     11:09          22851 texttable.py

我的Python脚本开头是这样的,单独运行完全没问题:

from openpyxl import load_workbook
import openpyxl.utils.cell
import pyexcel 
import os.path
import time

我也用pip show命令查过openpyxl和pyexcel,它们的安装路径完全一样:

PS C:\Users\username\AppData\Roaming\Python\Python313-32\site-packages> pip show openpyxl
Name: openpyxl
Version: 3.1.5
Summary: A Python library to read/write Excel 2010 xlsx/xlsm files
Home-page: https://openpyxl.readthedocs.io
Author: See AUTHORS
Author-email: charlie.clark@clark-consulting.eu
License: MIT
Location: C:\Users\username\AppData\Roaming\Python\Python313-32\site-packages
Requires: et-xmlfile
Required-by: pyexcel-xlsx


PS C:\Users\username\AppData\Roaming\Python\Python313-32\site-packages> pip show pyexcel
Name: pyexcel
Version: 0.7.1
Summary: A wrapper library that provides one API to read, manipulate and writedata in different excel formats
Home-page: https://github.com/pyexcel/pyexcel
Author: C.W.
Author-email: info@pyexcel.org
License: New BSD
Location: C:\Users\username\AppData\Roaming\Python\Python313-32\site-packages
Requires: lml, pyexcel-io, texttable
Required-by: pyexcel-cli

谢谢大家的帮助!

备注:内容来源于stack exchange,提问作者Brysinnbo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 10:09:34