簡體   English   中英

為什么“導入 pyPDF2”在安裝后不起作用?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM