【发布时间】:2020-09-14 22:51:00
【问题描述】:
问题总结:
使用 python 解释器,我输入 import pyPDF2 并得到一个 ModuleNotFound 错误,即使我已经安装了 pyPDF2 模块:
>>> import pyPDF2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyPDF2'
我尝试过的:
我正在使用 Windows 10。我是 python 新手。我已将 Python 3.8.3 安装到 C:\Python38 文件夹。我已经通过“pip install pyPDF2”安装了pyPDF2。 Windows 路径包括文件夹:C:\Python38\Scripts\;C:\Python38\。
在 Windows 命令提示符下,我键入“python”并获取:
c:\>python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
在 python 解释器提示符下,我输入“import pyPDF2”并得到:
>>> import pyPDF2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyPDF2'
>>>
注意:从 ArcGIS 安装中安装了旧版本的 python 2.7。这会引起冲突吗?如果没有,我宁愿不卸载那个版本,因为它与我使用的 ArcGIS 一起使用。
我真正想做的是将 7,696 个 pdf 文件自动连接成 104 个 pdf 文件。到目前为止,我的程序如下所示:
import os
from pyPDF2 import PdfFileMerger
source_dir = os.getcwd()
merger = PdfFileMerger()
for item in os.listdir(source_dir):
if item.beginswith('District001_Pg'):
merger.append(item)
merger.write('District001.pdf')
merger.close()
任何人都能够提供任何帮助将不胜感激!
【问题讨论】:
-
您可以通过执行与新 python 版本相同的测试来检查旧 python 版本中是否安装了 pyPDF2:启动解释器,然后键入 import pyPDF2。
标签: python python-3.x windows pypdf2 modulenotfounderror