Bonjour, j'ai un probleme avec patoolib pour extraire le contenu d'un fichier rar.
J'utilise bien des chemins absolu, l'erreur est bizarre... Aidez moi svp
Et e module est a jour : Requirement already up-to-date: patool in c:\users\theo\anaconda3\lib\site-packages
Code Python : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import patoolib
def unzip(filezip = "C:/Users/Anon/Desktop/1300001717.rar"):
    #check l'extention
    dirname = os.path.split(filezip)[0] + '/tmpData'
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    ext = os.path.split(filezip)[1].split('.')[-1]
 
    if ext == 'rar':
        #with rarfile.RarFile(filezip) as opened_rar:
        #    for f in opened_rar.infolist():
        #        print (f.filename, f.file_size)
        #    opened_rar.extractall(dirname)
        print(filezip, dirname)
        patoolib.extract_archive(filezip, dirname)#ERREUR...
    elif ext == 'zip':
        zfile = zipfile.ZipFile(filezip)
        for name in zfile.namelist():
            # filename = os.path.split(name)[1]
            zfile.extract(name, dirname)
        zfile.close()
 
    return os.path.split(filezip)[0]#Je renvoie le chemin pour lutiliser plus tard

Console :
C:/Users/Anon/Desktop/1300001717.rar C:/Users/Anon/Desktop/tmpData
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Anon\Anaconda3\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:/Users/Anon/.spyder-py3/AssetsManagement/Main.py", line 410, in <lambda>
bt = ttk.Button(win2, text="generer", command=lambda: generateData(file, win2))
File "C:/Users/Anon/.spyder-py3/AssetsManagement/Main.py", line 122, in generateData
dir0 = str(unzip(file))
File "C:/Users/Anon/.spyder-py3/AssetsManagement/Main.py", line 110, in unzip
patoolib.extract_archive(filezip, dirname)
File "C:\Users\Anon\Anaconda3\lib\site-packages\patoolib\__init__.py", line 682, in extract_archive
if verbosity >= 0:
TypeError: '>=' not supported between instances of 'str' and 'int'


PS : le code en commentaire est un autre essai qui ne fonctionne pas, ca me disait
File "C:\Users\Anon\Anaconda3\lib\site-packages\rarfile.py", line 2816, in custom_popen
raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL)
rarfile.RarCannotExec: Unrar not installed? (rarfile.UNRAR_TOOL='unrar')

Alors que j'ai deja installe unrar