conda-forge / torchtext-feedstock

A conda-smithy repository for torchtext.
BSD 3-Clause "New" or "Revised" License
0 stars 4 forks source link

Unable to import torchtext #10

Open jacquelinegarrahan opened 1 year ago

jacquelinegarrahan commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

I'm unable to import torchtext, prob because of this patch somehow (https://github.com/conda-forge/torchtext-feedstock/blob/832590d86886c56f59a212714a125543c3964afd/recipe/patches/0004-load-library-from-correct-place.patch#L19)

>>> import torch
>>> import torchtext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jacquelinegarrahan/miniconda3/envs/art-nbs/lib/python3.10/site-packages/torchtext/__init__.py", line 6, in <module>
    from torchtext import _extension  # noqa: F401
  File "/Users/jacquelinegarrahan/miniconda3/envs/art-nbs/lib/python3.10/site-packages/torchtext/_extension.py", line 7, in <module>
    _LIB_DIR = Path(os.environ["SP_DIR"]) / "torch" / "lib"
  File "/Users/jacquelinegarrahan/miniconda3/envs/art-nbs/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'SP_DIR'
>>> torchtext.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'torchtext' is not defined

Installed packages

# Name                    Version                   Build  Channel
accelerate                0.16.0             pyhd8ed1ab_0    conda-forge
aiofiles                  22.1.0             pyhd8ed1ab_0    conda-forge
aiosqlite                 0.18.0             pyhd8ed1ab_0    conda-forge
anyio                     3.5.0           py310hecd8cb5_0
appdirs                   1.4.4              pyhd3eb1b0_0
appnope                   0.1.2           py310hecd8cb5_1001
argon2-cffi               21.3.0             pyhd3eb1b0_0
argon2-cffi-bindings      21.2.0          py310hca72f7f_0
asttokens                 2.0.5              pyhd3eb1b0_0
attrs                     22.1.0          py310hecd8cb5_0
babel                     2.11.0          py310hecd8cb5_0
backcall                  0.2.0              pyhd3eb1b0_0
beautifulsoup4            4.11.1          py310hecd8cb5_0
bleach                    4.1.0              pyhd3eb1b0_0
brotli                    1.0.9                hca72f7f_7
brotli-bin                1.0.9                hca72f7f_7
brotlipy                  0.7.0           py310hca72f7f_1002
bzip2                     1.0.8                h1de35cc_0
ca-certificates           2023.01.10           hecd8cb5_0
catalogue                 2.0.7           py310hecd8cb5_0
certifi                   2022.12.7       py310hecd8cb5_0
cffi                      1.15.1          py310h6c40b1e_3
charset-normalizer        2.0.4              pyhd3eb1b0_0
click                     8.0.4           py310hecd8cb5_0
colorama                  0.4.6           py310hecd8cb5_0
comm                      0.1.2           py310hecd8cb5_0
contourpy                 1.0.5           py310haf03e11_0
cryptography              39.0.1          py310hf6deb26_0
cycler                    0.11.0             pyhd3eb1b0_0
cymem                     2.0.6           py310he9d5cce_0
cython-blis               0.7.7           py310h4e76f89_0
dataclasses               0.8                pyh6d0b6a4_7
debugpy                   1.5.1           py310he9d5cce_0
decorator                 5.1.1              pyhd3eb1b0_0
deepspeed                 0.8.0           cpu_py310h23b1c27_0    conda-forge
defusedxml                0.7.1              pyhd3eb1b0_0
diffusers                 0.13.1             pyhd8ed1ab_0    conda-forge
double-conversion         3.2.0                hf0c8a7f_1    conda-forge
entrypoints               0.4             py310hecd8cb5_0
executing                 0.8.3              pyhd3eb1b0_0
filelock                  3.9.0           py310hecd8cb5_0
flit-core                 3.6.0              pyhd3eb1b0_0
fonttools                 4.25.0             pyhd3eb1b0_0
freetype                  2.12.1               hd8bbffd_0
future                    0.18.3          py310hecd8cb5_0
giflib                    5.2.1                h6c40b1e_3
hjson-py                  3.1.0              pyhd8ed1ab_0    conda-forge
huggingface_hub           0.12.1             pyhd8ed1ab_0    conda-forge
idna                      3.4             py310hecd8cb5_0
importlib-metadata        4.11.3          py310hecd8cb5_0
importlib_metadata        4.11.3               hd3eb1b0_0
ipykernel                 6.19.2          py310h20db666_0
ipython                   8.10.0          py310hecd8cb5_0
ipython_genutils          0.2.0              pyhd3eb1b0_1
jedi                      0.18.1          py310hecd8cb5_1
jinja2                    3.1.2           py310hecd8cb5_0
joblib                    1.1.1           py310hecd8cb5_0
jpeg                      9e                   h6c40b1e_1
json5                     0.9.6              pyhd3eb1b0_0
jsonschema                4.17.3          py310hecd8cb5_0
jupyter_client            7.4.9           py310hecd8cb5_0
jupyter_core              5.2.0           py310hecd8cb5_0
jupyter_events            0.6.3              pyhd8ed1ab_0    conda-forge
jupyter_server            1.23.4          py310hecd8cb5_0
jupyter_server_fileid     0.8.0              pyhd8ed1ab_0    conda-forge
jupyter_server_ydoc       0.6.1              pyhd8ed1ab_0    conda-forge
jupyter_ydoc              0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab                3.6.1              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2                      py_0
jupyterlab_server         2.19.0          py310hecd8cb5_0
kiwisolver                1.4.4           py310hcec6c5f_0
langcodes                 3.3.0              pyhd3eb1b0_0
lcms2                     2.12                 hf1fd2bf_0
lerc                      3.0                  he9d5cce_0
libabseil                 20230125.0      cxx17_hf0c8a7f_1    conda-forge
libblas                   3.9.0           16_osx64_openblas    conda-forge
libbrotlicommon           1.0.9                hca72f7f_7
libbrotlidec              1.0.9                hca72f7f_7
libbrotlienc              1.0.9                hca72f7f_7
libcblas                  3.9.0           16_osx64_openblas    conda-forge
libcxx                    14.0.6               h9765a3e_0
libdeflate                1.17                 hb664fd8_0
libffi                    3.4.2                hecd8cb5_6
libgfortran               5.0.0           11_3_0_hecd8cb5_28
libgfortran5              11.3.0              h9dfd629_28
liblapack                 3.9.0           16_osx64_openblas    conda-forge
libopenblas               0.3.21               h54e7dc3_0
libpng                    1.6.39               h6c40b1e_0
libprotobuf               3.21.12              hbc0c0cd_0    conda-forge
libsentencepiece          0.1.97               h493ac8d_1    conda-forge
libsodium                 1.0.18               h1de35cc_0
libtiff                   4.5.0                hcec6c5f_2
libutf8proc               2.8.0                hb7f2c08_0    conda-forge
libuv                     1.44.2               h6c40b1e_0
libwebp                   1.2.4                hf6ce154_1
libwebp-base              1.2.4                h6c40b1e_1
libzlib                   1.2.13               hfd90126_4    conda-forge
llvm-openmp               14.0.6               h0dcd299_0
lz4-c                     1.9.4                hcec6c5f_0
markupsafe                2.1.1           py310hca72f7f_0
matplotlib                3.7.0           py310h2ec42d9_0    conda-forge
matplotlib-base           3.7.0           py310ha533b9c_0
matplotlib-inline         0.1.6           py310hecd8cb5_0
mistune                   0.8.4           py310hca72f7f_1000
mkl                       2022.2.1         h44ed08c_16952    conda-forge
munkres                   1.1.4                      py_0
murmurhash                1.0.7           py310he9d5cce_0
nbclassic                 0.5.2           py310hecd8cb5_0
nbclient                  0.5.13          py310hecd8cb5_0
nbconvert                 6.4.4           py310hecd8cb5_0
nbformat                  5.7.0           py310hecd8cb5_0
ncurses                   6.4                  hcec6c5f_0
nest-asyncio              1.5.6           py310hecd8cb5_0
ninja                     1.10.2               hecd8cb5_5
ninja-base                1.10.2               haf03e11_5
nltk                      3.7                pyhd3eb1b0_0
notebook                  6.5.2           py310hecd8cb5_0
notebook-shim             0.2.2           py310hecd8cb5_0
numpy                     1.24.2          py310h788a5b3_0    conda-forge
openssl                   1.1.1t               hca72f7f_0
packaging                 22.0            py310hecd8cb5_0
pandas                    1.5.3           py310hecf8f37_0    conda-forge
pandocfilters             1.5.0              pyhd3eb1b0_0
parso                     0.8.3              pyhd3eb1b0_0
pathy                     0.10.1          py310hecd8cb5_0
patsy                     0.5.3           py310hecd8cb5_0
pexpect                   4.8.0              pyhd3eb1b0_3
pickleshare               0.7.5           pyhd3eb1b0_1003
pillow                    9.4.0           py310hcec6c5f_0
pip                       23.0.1             pyhd8ed1ab_0    conda-forge
platformdirs              2.5.2           py310hecd8cb5_0
pooch                     1.4.0              pyhd3eb1b0_0
preshed                   3.0.6           py310he9d5cce_0
prometheus_client         0.14.1          py310hecd8cb5_0
prompt-toolkit            3.0.36          py310hecd8cb5_0
protobuf                  4.21.12         py310h7a76584_0    conda-forge
psutil                    5.9.0           py310hca72f7f_0
ptyprocess                0.7.0              pyhd3eb1b0_2
pure_eval                 0.2.2              pyhd3eb1b0_0
py-cpuinfo                8.0.0              pyhd3eb1b0_1
pycparser                 2.21               pyhd3eb1b0_0
pydantic                  1.10.5                   pypi_0    pypi
pygments                  2.11.2             pyhd3eb1b0_0
pyopenssl                 23.0.0          py310hecd8cb5_0
pyparsing                 3.0.9           py310hecd8cb5_0
pyrsistent                0.18.0          py310hca72f7f_0
pysocks                   1.7.1           py310hecd8cb5_0
python                    3.10.9               h218abb5_0
python-dateutil           2.8.2              pyhd3eb1b0_0
python-fastjsonschema     2.16.2          py310hecd8cb5_0
python-json-logger        2.0.7              pyhd8ed1ab_0    conda-forge
python_abi                3.10                    2_cp310    conda-forge
pytorch                   1.13.1          cpu_py310h2bbf33f_1    conda-forge
pytz                      2022.7          py310hecd8cb5_0
pyyaml                    6.0             py310h6c40b1e_1
pyzmq                     23.2.0          py310he9d5cce_0
re2                       2023.02.02           hf0c8a7f_0    conda-forge
readline                  8.2                  hca72f7f_0
regex                     2022.7.9        py310hca72f7f_0
replicate                 0.5.0                    pypi_0    pypi
requests                  2.28.1          py310hecd8cb5_1
revtok                    0.0.3.1            pyhd8ed1ab_0    conda-forge
rfc3339-validator         0.1.4              pyhd8ed1ab_0    conda-forge
rfc3986-validator         0.1.1              pyh9f0ad1d_0    conda-forge
sacremoses                0.0.43             pyhd3eb1b0_0
safetensors               0.2.8           py310hb28ce15_2    conda-forge
scipy                     1.10.0          py310h240c617_2    conda-forge
seaborn                   0.12.2               hd8ed1ab_0    conda-forge
seaborn-base              0.12.2             pyhd8ed1ab_0    conda-forge
send2trash                1.8.0              pyhd3eb1b0_1
setuptools                65.6.3          py310hecd8cb5_0
shellingham               1.5.0           py310hecd8cb5_0
six                       1.16.0             pyhd3eb1b0_1
sleef                     3.5.1                h6db0672_2    conda-forge
smart_open                5.2.1           py310hecd8cb5_0
sniffio                   1.2.0           py310hecd8cb5_1
soupsieve                 2.3.2.post1     py310hecd8cb5_0
spacy                     3.3.1           py310h7ff4b7e_0
spacy-legacy              3.0.9           py310hecd8cb5_0
spacy-loggers             1.0.1              pyhd3eb1b0_0
sqlite                    3.41.1               h6c40b1e_0
srsly                     2.4.6           py310hcec6c5f_0
stack_data                0.2.0              pyhd3eb1b0_0
statsmodels               0.13.5          py310h7b7cdfe_1
tbb                       2021.7.0             ha357a0b_0
terminado                 0.17.1          py310hecd8cb5_0
testpath                  0.6.0           py310hecd8cb5_0
thinc                     8.0.15          py310h7ff4b7e_0
tk                        8.6.12               h5d9f67b_0
tokenizers                0.11.4          py310h8776b5c_1
tomli                     2.0.1           py310hecd8cb5_0
torchtext                 0.14.1          py310he9dc201_3    conda-forge
torchvision               0.13.1          cpu_py310hc47236b_0
tornado                   6.2             py310hca72f7f_0
tqdm                      4.64.1          py310hecd8cb5_0
traitlets                 5.7.1           py310hecd8cb5_0
transformers              4.26.1                     py_0    huggingface
typer                     0.4.1           py310hecd8cb5_0
typing-extensions         4.4.0           py310hecd8cb5_0
typing_extensions         4.4.0           py310hecd8cb5_0
tzdata                    2022g                h04d1e81_0
urllib3                   1.26.14         py310hecd8cb5_0
wasabi                    0.9.1           py310hecd8cb5_0
wcwidth                   0.2.5              pyhd3eb1b0_0
webencodings              0.5.1           py310hecd8cb5_1
websocket-client          0.58.0          py310hecd8cb5_4
wheel                     0.38.4          py310hecd8cb5_0
xz                        5.2.10               h6c40b1e_1
y-py                      0.5.9           py310hb28ce15_0    conda-forge
yaml                      0.2.5                haf1e3a3_0
ypy-websocket             0.8.2              pyhd8ed1ab_0    conda-forge
zeromq                    4.3.4                h23ab428_0
zipp                      3.11.0          py310hecd8cb5_0
zlib                      1.2.13               hfd90126_4    conda-forge
zstd                      1.5.2                hcb37349_0

Environment info

active environment : art-nbs
    active env location : /Users/jacquelinegarrahan/miniconda3/envs/art-nbs
            shell level : 2
       user config file : /Users/jacquelinegarrahan/.condarc
 populated config files : /Users/jacquelinegarrahan/.condarc
          conda version : 22.9.0
    conda-build version : not installed
         python version : 3.9.12.final.0
       virtual packages : __osx=10.16=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /Users/jacquelinegarrahan/miniconda3  (writable)
      conda av data dir : /Users/jacquelinegarrahan/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /Users/jacquelinegarrahan/miniconda3/pkgs
                          /Users/jacquelinegarrahan/.conda/pkgs
       envs directories : /Users/jacquelinegarrahan/miniconda3/envs
                          /Users/jacquelinegarrahan/.conda/envs
               platform : osx-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.12 Darwin/22.3.0 OSX/10.16
                UID:GID : 501:20
             netrc file : None
           offline mode : False

           offline mode : False
h-vetinari commented 1 year ago

I'm unable to import torchtext, prob because of this patch somehow [...]

No, it's because you're mixing channels, which is not supported by conda-forge (it may work, but if it breaks - like here -, too bad).

As described in the README of every feedstock, please do

conda config --add channels conda-forge
conda config --set channel_priority strict

and try again.

Hacker1337 commented 11 months ago

Reinstalling torch and torchtext from pytorch channel resolved this issue for me.

conda uninstall torchtext
conda install torchtext -c pytorch