[英]'import pyPDF2' results in 'ModuleNotFoundError'
问题摘要:使用 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()
任何人都能够提供的任何帮助将不胜感激!
如果你想在同一台机器上运行 2 个不同版本的 python 而不会发生冲突,你可以使用 VirtualEnv。 这是我在 web 上找到的文档,可帮助您入门。 https://www.freecodecamp.org/news/installing-multiple-python-versions-on-windows-using-virtualenv/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.