Plugin error from diversity: 'latin-1' codec can't encode character '\u03b2' (...)


I've been getting the following error when running the "qiime diversity core-metrics-phylogenetic" command:

Plugin error from diversity:
'latin-1' codec can't encode character '\u03b2' in position 3464: ordinal not in range(256)

I'm unable to find any bad character (specifically \u03b2 which stands for greek beta) in any of my files, as the message suggests. The input files include my metadata file (which is very simple, attached below), ASV feature table as created by dada2 plugin, and a phylogenetic tree as created by fragment-insertion plugin, sepp algorithm.

metadata_barcodes_only.tsv (6.6 KB)

The command I ran (nothing special):

qiime diversity core-metrics-phylogenetic \
	  --i-phylogeny sepp_rooted_tree.qza \
	  --i-table feature_table.qza \
	  --p-sampling-depth 15227 \
	  --m-metadata-file metadata_barcodes_only.tsv \
	  --output-dir Diversity

Log file output:

/conda/envs/qiime2/lib/python3.6/site-packages/sklearn/metrics/ DataConversionWarning: Data was converted to boolean for metric jaccard
warnings.warn(msg, DataConversionWarning)
/conda/envs/qiime2/lib/python3.6/site-packages/skbio/stats/ordination/ RuntimeWarning: The result contains negative eigenvalues. Please compare their magnitude with the magnitude of some of the largest positive eigenvalues. If the negative ones are smaller, it's probably safe to ignore them, but if they are large in magnitude, the results won't be useful. See the Notes section for more details. The smallest eigenvalue is -0.09186268763487035 and the largest is 2.8949291936192294.
Traceback (most recent call last):
File "/conda/envs/qiime2/lib/python3.6/site-packages/q2cli/", line 327, in call
results = action(**arguments)
File "</conda/envs/qiime2/lib/python3.6/site-packages/>", line 2, in core_metrics_phylogenetic
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/", line 240, in bound_callable
output_types, provenance)
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/", line 477, in callable_executor
outputs = self._callable(scope.ctx, **view_args)
File "/conda/envs/qiime2/lib/python3.6/site-packages/q2_diversity/", line 59, in core_metrics_phylogenetic
metric='unweighted_unifrac', n_jobs=n_jobs)
File "</conda/envs/qiime2/lib/python3.6/site-packages/>", line 2, in beta_phylogenetic
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/", line 240, in bound_callable
output_types, provenance)
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/", line 411, in callable_executor
spec.qiime_type, output_view, spec.view_type, prov)
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/", line 273, in _from_view
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/core/archive/", line 316, in from_data
Format.write(rec, type, format, data_initializer, provenance_capture)
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/core/archive/format/", line 21, in write
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/core/archive/format/", line 26, in write
prov_dir, [root / cls.METADATA_FILE, archive_record.version_fp])
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/core/archive/", line 313, in finalize
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/core/archive/", line 304, in write_citations_bib / self.CITATION_FILE))
File "/conda/envs/qiime2/lib/python3.6/site-packages/qiime2/core/", line 71, in save
bp.dump(db, f, writer=writer)
File "/conda/envs/qiime2/lib/python3.6/site-packages/bibtexparser/", line 111, in dump
UnicodeEncodeError: 'latin-1' codec can't encode character '\u03b2' in position 3464: ordinal not in range(256)

Additional details:
qiime version: 2019.7.0

Any help would be much appreciated!

1 Like

Hey @efratm!

I think this is the first time I’ve seen someone with the latin-1 encoding (which is weird as it used to be a super common standard).

There’s not necessarily any bad characters here, rather latin-1 just cannot express some symbols. What strikes me as odd is that QIIME 2 is attempting to use latin-1 at all. It looks like perhaps we did not specify utf-8 (which can encode all characters) to our bibtex library, and so it must be using a default?

Where it is getting that default is less clear, I would guess that it’s your environment configuration, so let’s see if that’s true:

env | grep "LC\|LANG\|LANGUAGE"

That command will tell us how your environment’s locale is configured, and we can brainstorm from there.

Thanks @ebolyen,
This is what I got when running your command:


Also, it just happened with another dataset on our server, confirming something’s off in the environment not the specific files.

Many many thanks for your help.

Thanks for the output @efratm!

Looks like it is indeed just a locale misconfiguration. If you run this command:

locale -a

You will get a list of all available locals. We want one that uses a prefix matching the language you want, and that ends in some variant of utf8/UTF-8/UTF8. Once you’ve identified one, try setting this variable:

export LC_ALL="<the one you picked, no angle-brackets>"

That should clear up the issue you are having with QIIME 2 (you may want to put the above command in something like a ~/.bashrc file to save it beyond a single session)


Thanks again @ebolyen!! That indeed solved the issue.

1 Like


I am having the same plugin error with the same version of qiime. When I check my environment configuration though I get something ending in UTF-8 (output below)
I was wondering if you had any advice?
code that I tried to run

qiime diversity core-metrics-phylogenetic \ --i-phylogeny rooted-tree.qza \ --i-table table.qza \ --p-sampling-depth 1200 \ --m-metadata-file arctic_manifest.txt \ --output-dir core-metric-results arctic_manifest.txt (63.7 KB)

Can you please provide the error message you are receiving? Many error messages look the same but are actually subtly different…


PS - sorry for the slow reply, somehow this fell off our radar at Q2 HQ