问题总结:使用 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
文件夹中。我已经pyPDF2
通过“pip install 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()
任何人能够提供的任何帮助都将不胜感激!