English 中文(简体)
不存在“直接}” 执业 rror: 进口舱内不存在固定/固定
原标题:raise RuntimeError(f"Directory {directory} does not exist") RuntimeError: Directory static/ does not exist from import fitz
  • 时间:2021-06-15 08:32:19
  •  标签:
  • python

我在从中抽取_卷:

RuntimeError(f“Directory {directory} does not exist”)
RuntimeError: Directory static/ does not exist from import fitz

I don t understand why this sends me back this error message. I saw the conversation dealing with this topic before but I did not understand the solution. Could you help me?

该档案旨在从国防军档案中提取某些图像。

from os import chdir
import shutil, os
import io
from PIL import Image
import fitz
from unif_noun import unif_noun #other file python for change file noun.

def execute_func(rootdir):
for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        filepath = subdir + os.sep + file
        if filepath.endswith(".pdf"):
            #extract(f"{filepath}")
            # open the file
            pdf_file = fitz.open(file)
            images = list()
            for page_index in range(len(pdf_file)):
                # get the page itself
                page = pdf_file[page_index]
                image_list = page.getImageList()
                # printing number of images found in this page
                # if image_list:
                #     print(f"[+] Found a total of {len(image_list)} images in page {page_index}")
                # else:
                #     print("[!] No images found on page", page_index)
                for image_index, img in enumerate(page.getImageList(), start=1):
                    images.append(img[0])
            for i, xref in enumerate(images, start=1):
                if 1 < i < len(images) - 3:
                    # extract the image bytes
                    base_image = pdf_file.extractImage(xref)
                    image_bytes = base_image["image"]
                    # get the image extension
                    image_ext = base_image["ext"]
                    # load it to PIL
                    image = Image.open(io.BytesIO(image_bytes))
                    # save it to local disk
                    image.save(open(f"{unif_noun(file)}.{image_ext}", "wb"))
                    # Déplacer un fichier du répertoire
                    for subdir, dirs, files in os.walk(rootdir):
                        for f in files:
                            source = subdir
                            destination =  C:/Users/.../VS Projects/img 
                            filename = os.path.basename(source)
                            dest = os.path.join(destination,filename)
                            shutil.move(source + f"{unif_noun(file)}.{image_ext}", dest)
execute_func(r C:/Users/Factoryz Amandine/OneDrive/Bureau/Python/CCOR02752150_3.pdf )[enter image description here][1]
问题回答

http://www.ohchr.org。

pip uninstall fitz

www.un.org/Depts/DGACM/index_spanish.htm Install pymupdf model

pip install pymupdf

来源: Unable to usefitz with python 3.8

我有同样的问题,并安装了<代码>PyMuPDF,固定在我身上。 (这并不是第一次安装<代码>PyMuPDF。) 解决其他与适当有关的问题

pip3 install PyMuPDF




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签