RESCRIPt: AttributeError: '_io.TextIOWrapper' object has no attribute 'rstrip'

Please read the following before posting!

Dear All,

I am following this tutorial How to train a GTDB SSU classifier using RESCRIPt. and the command:

qiime rescript evaluate-fit-classifier \
    --i-sequences gtdb-214-both-seqs.qza  \
    --i-taxonomy gtdb-214-both-tax.qza \
    --p-n-jobs 32 \
    --o-classifier gtdb-214-both-classifier_2.qza \
    --o-observed-taxonomy gtdb-214-both-predicted-taxonomy_2.qza \
    --o-evaluation gtdb-214-both-classifier-evaluation_2.qzv \

throws the following error

/path/to/qiime2-2023.2/lib/python3.8/site-packages/rescript/ FutureWarning: Passing a set as an indexer is deprecated and will raise in a future version. Use a list instead.
  taxa = taxa.loc[seq_ids]
Validation: 3.39s
/path/to/qiime2-2023.2/lib/python3.8/site-packages/q2_feature_classifier/ UserWarning: The TaxonomicClassifier artifact that results from this method was trained using scikit-learn version 0.24.1. It cannot be used with other versions of scikit-learn. (While the classifier may complete successfully, the results will be unreliable.)
  warnings.warn(warning, UserWarning)
Training: 2700.10s

Classification: 737.18s
/path/to/qiime2-2023.2/lib/python3.8/site-packages/rescript/ UserWarning: The lists of input taxonomies and labels are different lengths. Additional taxonomies will be labeled numerically by their order in the inputs. Note that if these numbers match existing labels, those data will be grouped in the visualization.
  warnings.warn(msg, UserWarning)
Traceback (most recent call last):
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/q2cli/", line 417, in __call__
    results = action(**arguments)
  File "<decorator-gen-481>", line 2, in evaluate_fit_classifier
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/sdk/", line 211, in bound_callable
    outputs = self._callable_executor_(scope, callable_args,
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/sdk/", line 439, in _callable_executor_
    outputs = self._callable(scope.ctx, **view_args)
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/rescript/", line 53, in evaluate_fit_classifier
    evaluation, = _eval([taxonomy], [observed_taxonomy])
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/sdk/", line 112, in deferred_action
    return action_obj._bind(
  File "<decorator-gen-547>", line 2, in evaluate_classifications
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/sdk/", line 211, in bound_callable
    outputs = self._callable_executor_(scope, callable_args,
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/sdk/", line 439, in _callable_executor_
    outputs = self._callable(scope.ctx, **view_args)
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/rescript/", line 204, in evaluate_classifications
    plots, = volatility(metadata=q2.Metadata(precision_recall),
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/sdk/", line 75, in deferred_action
    invocation = HashableInvocation(plugin_action, arguments)
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/core/type/", line 691, in __init__
    self.arguments = self._make_hashable(unified_arguments)
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/core/type/", line 741, in _make_hashable
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/core/type/", line 738, in _make_hashable
    new_collection.append((k, self._make_hashable(v)))
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/core/type/", line 746, in _make_hashable
  File "/path/to/qiime2-2023.2/lib/python3.8/site-packages/qiime2/metadata/", line 250, in save
    filepath = filepath.rstrip('.')
AttributeError: '_io.TextIOWrapper' object has no attribute 'rstrip'

I am using qiime2-2023.2 installed with conda. RESCRIPt was installed following Option 2: Install within QIIME 2 environment

Thank you!

Hi @kafker ,
Thanks for reporting! We have not seen this error before, so it might be related to the very very recent release of GTDB 214 (just a few days ago; we have not had time to extensively test yet). We will investigate.

As a workaround for now, you can train a classifier with q2-feature-classifier instead (as shown in the previous step of that tutorial, so you have probably done this already).

Just out of curiosity, what kind of environment are you running this in? I see that you are running qiime2-2023.2 — but what other plugins or packages have you installed in that environment?

Hi Nicholas,

I got the same error with GTDB v207.

RESCRIPt was installed within a fresh qiime2-2023.2 environment. This is the output of qiime info

System versions
Python version: 3.8.15
QIIME 2 release: 2023.5
QIIME 2 version: 2023.5.0.dev0+4.gfe49136
q2cli version: 2023.5.0.dev0+2.g259ffd6

Installed plugins
alignment: 2023.5.0.dev0
composition: 2023.5.0.dev0
cutadapt: 2023.5.0.dev0
dada2: 2023.5.0.dev0
deblur: 2023.5.0.dev0
demux: 2023.5.0.dev0
diversity: 2023.5.0.dev0
diversity-lib: 2023.5.0.dev0
emperor: 2023.5.0.dev0
feature-classifier: 2023.5.0.dev0
feature-table: 2023.5.0.dev0
fragment-insertion: 2023.5.0.dev0
gneiss: 2023.5.0.dev0
longitudinal: 2023.5.0.dev0
metadata: 2023.5.0.dev0
phylogeny: 2023.5.0.dev0
quality-control: 2023.5.0.dev0
quality-filter: 2023.5.0.dev0
rescript: 2023.2.0+2.ged0344d
sample-classifier: 2023.5.0.dev0+1.g4c16d88
taxa: 2023.5.0.dev0
types: 2023.5.0.dev0+2.g8c5db7b
types-genomics: 2023.5.0.dev0+3.gfaadb7b
vsearch: 2023.5.0.dev0

Application config directory

Getting help
To get help with QIIME 2, visit

I have another qiime2-2023.2 freshly installed on a different machine. I will install and test RESCRIPt there to see if the same error happen again. Maybe something went wrong with the installation of RESCRIPt.

Thank you

Hi @kafker,
I've encountered the same issue as well. The difference is that I was following this tutorial:

Using RESCRIPt's 'extract-seq-segments' to extract reference sequences without PCR primer pairs.

It seems highly likely that is related to qiime2-2023.2. I also have qiime2-2022.11 in my conda environment, and when I run 'qiime rescript evaluate-fit-classifier' in that environment (with RESCRIPt installed), I don't encounter any errors. I recommend giving it a try with qiime2-2022.11 to see if it resolves the issue for you.
Best of luck!


Hi @kafker,

Thank you for your patience. The issue is indeed as @antias suggests: it is a (transient) issue with the latest versions (developer versions) of RESCRIPt and QIIME 2 that you have installed. The developer version has the get-gtdb-data action that you are using, but is not yet officially released and is not fully stable.

The solution:

  1. you can use the developer version for now to run get-gtdb-data but not evaluate-fit-classifier. Instead use qiime feature-classifier fit-classifier-naive-bayes.
  2. if you want to run evaluate-fit-classifier on the GTDB database, you must either (1) switch to another QIIME 2 environment and install an earlier tagged release (i.e., stable release version) of RESCRIPt or (2) wait another few weeks for when the 2023.5 stable release should be ready, then re-install RESCRIPt in a fresh QIIME 2 2023.5 environment. It should be fine to create the GTDB database files with the dev version of RESCRIPt, then switch to a non-dev environment to run evalute-fit-classifier.

Good luck!


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.