简体   繁体   English

'pip3 install patool' 后无法使用 patoolib

[英]Unable to use patoolib after 'pip3 install patool'

I am using a macbook, and have python3 installed and using spyder .我正在使用 macbook,并安装了python3并使用spyder

I have installed patool and it's listed in pip3 list .我已经安装了patool ,它在pip3 list中列出。

When I import patoolib and run the program it says, ModuleNotFoundError: No module named 'patoolib'当我导入patoolib并运行它说的程序时, ModuleNotFoundError: No module named 'patoolib'

So I am not able to run the extract related programs.所以我无法运行提取相关的程序。

import patoolib
import os
import glob

def extract_files(inputdir = '/Users/satishvadlamudi/Python_spyder_projects/zipped',outputdir = '/Users/satishvadlamudi/Python_spyder_projects/extracted'):
    os.chdir(inputdir)
    archives = glob.glob('*.gz')
    #print(archives)
    if not os.path.exists(outputdir):
        os.mkdirs(outputdir)
    files = os.listdir('/Users/satishvadlamudi/Python_spyder_projects/extracted')
    print (files)
    for archive in archives:
        if archive[:-3] not in files:
            patoolib.extract_archive(archive, outdir = outputdir)

Note that "pip" is also a python module.请注意,“pip”也是一个 python 模块。 If you see pip3 list give you the module installed but python3 complaint about ModuleNotFoundError, you may want to check if pip3 and python3 mean the same thing.如果您看到pip3 list为您提供了已安装的模块,但python3抱怨 ModuleNotFoundError,您可能需要检查pip3python3是否表示相同的意思。

Try with python3 -m pip list -v , which the -v tells you the installed location as well.尝试使用python3 -m pip list -v-v也会告诉你安装的位置。 If you see the module there, then the same python3 interpretor should be able to find the module.如果您在那里看到该模块,那么同一个python3解释器应该能够找到该模块。 If not, you may want to consider setting up PYTHONPATH env variable.如果没有,您可能需要考虑设置PYTHONPATH环境变量。

In order to import :为了导入

import patoolib

you need to install patool first:你需要先安装patool:

pip install patool

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM