[Dependency Bug]`sentencepiece` is not installed as a dependency in conda
See original GitHub issue🐛 Bug
Describe the bug
After installing the torchtext
, and trying the code below (in the repro section) an error pops up: ModuleNotFoundError: No module named 'sentencepiece'
. I think the package should be installed automatically as a dependency.
The problem is that the depndency on sentencepiece
is specified for pip, but not for conda (see attachments)
To Reproduce
After installing using
conda install -c pytorch torchtext
run the following:
from torchtext import data
from torchtext import datasets
imdb_set = datasets.IMDB(DATA_PATH,
text_field=data.Field(),
label_field=data.LabelField())
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-019e470b76d6> in <module>
----> 1 from torchtext import data
2 from torchtext import datasets
3
4 imdb_set = datasets.IMDB(DATA_PATH,
5 text_field=data.Field(),
~/miniconda3/envs/py37-ml/lib/python3.7/site-packages/torchtext/__init__.py in <module>
----> 1 from . import data
2 from . import datasets
3 from . import utils
4 from . import vocab
5 from . import experimental
~/miniconda3/envs/py37-ml/lib/python3.7/site-packages/torchtext/data/__init__.py in <module>
8 from .pipeline import Pipeline
9 from .utils import get_tokenizer, interleave_keys
---> 10 from .functional import generate_sp_model, \
11 load_sp_model, \
12 sentencepiece_numericalizer, \
~/miniconda3/envs/py37-ml/lib/python3.7/site-packages/torchtext/data/functional.py in <module>
----> 1 import sentencepiece as spm
2 import re
3
4 __all__ = [
5 "generate_sp_model", "load_sp_model",
ModuleNotFoundError: No module named 'sentencepiece'
Expected behavior
If some core part of the torchtext
package is using a third-party package, it should be added as a dependency.
Screenshots
conda search --info torchtext
doesn’t list sentencepiece
as a dependency.
However, pip show torchtext
does:
Environment
Collecting environment information… PyTorch version: 1.4.0 Is debug build: No CUDA used to build PyTorch: 10.1
OS: Ubuntu 18.04.4 LTS GCC version: (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0 CMake version: version 3.10.2
Python version: 3.7 Is CUDA available: Yes CUDA runtime version: 10.1.243 GPU models and configuration: GPU 0: GeForce GT 730 GPU 1: GeForce RTX 2080 Ti
Nvidia driver version: 440.44 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5 /usr/local/cuda-10.0/targets/x86_64-linux/lib/libcudnn.so.7.6.5 /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7.6.5 /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7.6.5
Versions of relevant libraries:
[pip] numpy==1.18.1
[pip] torch==1.4.0
[pip] torchaudio==0.4.0a0+719bcc7
[pip] torchsummary==1.5.1
[pip] torchtext==0.5.0
[pip] torchvision==0.5.0
[conda] blas 1.0 mkl
[conda] mkl 2020.0 166
[conda] mkl-service 2.3.0 py37he904b0f_0
[conda] mkl_fft 1.0.15 py37ha843d7b_0
[conda] mkl_random 1.1.0 py37hd6b4f25_0
[conda] pytorch 1.4.0 py3.7_cuda10.1.243_cudnn7.6.3_0 pytorch
[conda] torchaudio 0.4.0 py37 pytorch
[conda] torchsummary 1.5.1 pypi_0 pypi
[conda] torchtext 0.5.0 py_1 pytorch
[conda] torchvision 0.5.0 py37_cu101 pytorch
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (8 by maintainers)
Top GitHub Comments
As a temporary walkaround, users can install
sentencepiece
from channelpowerai
We will build our conda package in the similar way. https://github.com/pytorch/text/pull/726
Maybe to mitigate this problem, it is worth adding
pip
as a dependency in themeta.yaml
, and addingpip install sentencepiece==xx.xx
in thebuild
section?