[英]Why doesn't ''import pyPDF2'' work after installation?
这是我的代码,我收到此错误ModuleNotFoundError: No module named 'pyPDF2'
。
我已经安装了pip instal pyPDF2
。
如果我再试一次,它会说:
C:\Users\nicks\Desktop\Coding Projects\Python\Pdf to Audio›pip install PyPDF2
Requirement already satisfied: PyPDF2 in c: \users\nicks\appdata\local\packages \pythonsoftwarefoundation.python.3.9 qbz5n2kfra8p@\localcache\local
-packages \python39 \site-packages (1.26.0)
import pyPDF2
pdf = open('material.pdf','rb')
pdfReader = pyPDF2.PdFileReader(pdf)
speaker = pyttsx3.init()
speaker.say(pdf)
speaker.save_to_file(string, 'material.mp3')
speaker.runAndWait
我使用 Python 3.9.10。
!pip install install pypdf2
from PyPDF2 import PdfFileReader
with open('material.pdf', 'rb') as f:
pdf = PdfFileReader(f)
pdf
在将库名称从“pyPDF2”更改为“pypdf2”时,它没有给我任何 nomodule 错误。 我参考了此解决方案的以下链接。 看看有没有用? :) https://realpython.com/pdf-python/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.