Summary
When the deprecated fasttext distribution (e.g. fasttext==0.9.2) is installed in the same
Python environment as fast-langdetect, every call to fast_langdetect.detect(...) fails
with:
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when
needed
(no behavior change in NumPy 1.x).
The failure is silent at install time — pip reports both distributions as successfully
installed — and only surfaces on the first detect() call.
Reproduction
python -m venv /tmp/repro && source /tmp/repro/bin/activate
pip install "fast-langdetect==1.0.0" "fasttext==0.9.2"
python -c "import fast_langdetect; print(fast_langdetect.detect('hello world', model='lite'))"
Output:
Warning : `load_model` does not return WordVectorModel or SupervisedModel any more, ...
Traceback (most recent call last):
...
File ".../fast_langdetect/infer.py", line 343, in detect
labels, scores = ft_model.predict(normalized_text, k=k, threshold=threshold)
File ".../fasttext/FastText.py", line 232, in predict
return labels, np.array(probs, copy=False)
ValueError: Unable to avoid copy while creating an array as requested.
The same reproduction succeeds (returns a normal language prediction) when only
fasttext-predict is installed.
Root cause
fast-langdetect>=1.0.0 declares its dependency as fasttext-predict, a maintained,
NumPy-2-clean fork that exposes only the predict path.
- Both the deprecated
fasttext distribution and fasttext-predict install files into
the same top-level fasttext/ package directory (__init__.py, FastText.py,
fasttext_pybind.*.so). Because the distribution names differ, pip treats them as unrelated
and silently lets whichever is installed last overwrite the other's files. Verified locally:
pip uninstall fasttext removes the entire fasttext/ directory even though
fasttext-predict still claims it.
- The deprecated
fasttext.FastText._FastText.predict ends with:
return labels, np.array(probs, copy=False)
Under NumPy ≥ 2.0, copy=False raises if a copy can't be avoided; from a Python tuple of
floats, a copy can't be avoided, so it always raises.
fast_langdetect.detect(...) calls ft_model.predict(...) → ValueError.
Why this matters
Many environments have the legacy fasttext installed transitively (a common dep through
gensim plugins, langid wrappers, embedding libs, etc.). Adding fast-langdetect to such an
environment produces a hard runtime failure with no actionable hint pointing at the packaging
conflict — the traceback points into fasttext/FastText.py, which most users don't realize is
the wrong distribution.
Environment
- Python 3.12.x
fast-langdetect==1.0.0
fasttext==0.9.2 (deprecated)
fasttext-predict==0.9.2.4 (also installed; overwritten by fasttext on disk)
numpy>=2.0
- Linux x86_64
Summary
When the deprecated
fasttextdistribution (e.g.fasttext==0.9.2) is installed in the samePython environment as
fast-langdetect, every call tofast_langdetect.detect(...)failswith:
The failure is silent at install time — pip reports both distributions as successfully
installed — and only surfaces on the first
detect()call.Reproduction
Output:
The same reproduction succeeds (returns a normal language prediction) when only
fasttext-predictis installed.Root cause
fast-langdetect>=1.0.0declares its dependency asfasttext-predict, a maintained,NumPy-2-clean fork that exposes only the predict path.
fasttextdistribution andfasttext-predictinstall files intothe same top-level
fasttext/package directory (__init__.py,FastText.py,fasttext_pybind.*.so). Because the distribution names differ, pip treats them as unrelatedand silently lets whichever is installed last overwrite the other's files. Verified locally:
pip uninstall fasttextremoves the entirefasttext/directory even thoughfasttext-predictstill claims it.fasttext.FastText._FastText.predictends with:copy=Falseraises if a copy can't be avoided; from a Python tuple offloats, a copy can't be avoided, so it always raises.
fast_langdetect.detect(...)callsft_model.predict(...)→ValueError.Why this matters
Many environments have the legacy
fasttextinstalled transitively (a common dep throughgensim plugins, langid wrappers, embedding libs, etc.). Adding
fast-langdetectto such anenvironment produces a hard runtime failure with no actionable hint pointing at the packaging
conflict — the traceback points into
fasttext/FastText.py, which most users don't realize isthe wrong distribution.
Environment
fast-langdetect==1.0.0fasttext==0.9.2(deprecated)fasttext-predict==0.9.2.4(also installed; overwritten byfasttexton disk)numpy>=2.0