cannot import name 'classify_consensus_vsearch'

In Python, within the qiime2-amplicon-2024.2-py38-linux-conda environment, I'm getting the following error:

>>> from qiime2.plugins.feature_classifier import classify_consensus_vsearch, extract_reads   Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'classify_consensus_vsearch' from 'qiime2.plugins.feature_classifier' (unknown location)

I'm trying to redo some database building with existing Python code, following this notebook, just at the beginning:

import Bio
from Bio import SeqIO
import os
import glob
import shutil
import tarfile
import tempfile
import pysam
import urllib.request
from zipfile import ZipFile
from os.path import abspath,exists,join
from collections import defaultdict
from qiime2 import Artifact
from qiime2.plugins.feature_classifier.methods import classify_consensus_vsearch, extract_reads
from qiime2.metadata import Metadata
from qiime2.plugins.feature_table.methods import filter_samples, merge, merge_seqs, merge_taxa, rarefy
from qiime2.plugins.taxa.methods import filter_table
from qiime2.plugins.feature_table.visualizers import summarize

I have no experience with the Python API (or Python as much) :confused: any suggestions what is wrong? I think all the other import commands worked without issues (or at least there was no error).


1 Like

Hello @lxsteiner,

Every QIIME 2 action has a docs page like this that shows how to invoke the action on the cli and in Python. If you go to that link it will show you how to import feature_classifier classify_consensus_vsearch.

Note that where it says pipelines in that import it could also say methods or visualizers depending on the specific type of action you're using. In all cases, you can put actions there instead of the specific action type, and the import will still work.

1 Like

Thank you @Oddant1 I only worked with the CLI, my eyes never even noticed there to be an API tab on the docs pages...

The import command changed in the recent versions, that's why it didn't work. Oh well, should've have anticipated that. :smiling_face_with_tear:

1 Like