explosion / spacy-llm

🦙 Integrating LLMs into structured NLP pipelines
https://spacy.io/usage/large-language-models
MIT License
1.13k stars 87 forks source link

ModuleNotFoundError: No module named 'spacy.language'; 'spacy' is not a package #391

Closed nxitik closed 11 months ago

nxitik commented 11 months ago

Traceback (most recent call last): File "/home/ec2-user/spacy/spacy.py", line 8, in from spacy_llm.util import assemble File "/home/ec2-user/.conda/envs/naitik2/lib/python3.10/site-packages/spacy_llm/init.py", line 1, in from . import cache # noqa: F401 File "/home/ec2-user/.conda/envs/naitik2/lib/python3.10/site-packages/spacy_llm/cache.py", line 7, in from spacy.tokens import Doc, DocBin File "/home/ec2-user/spacy/spacy.py", line 8, in from spacy_llm.util import assemble File "/home/ec2-user/.conda/envs/naitik2/lib/python3.10/site-packages/spacy_llm/util.py", line 5, in from spacy.language import Language ModuleNotFoundError: No module named 'spacy.language'; 'spacy' is not a package

What could be the issue? I am able to use it on Google colab

nxitik commented 11 months ago

pip list

Package Version


absl-py 2.0.0 accelerate 0.24.1 aiofiles 23.2.1 aiohttp 3.8.6 aiosignal 1.3.1 altair 5.1.2 annotated-types 0.6.0 anyio 3.7.1 appdirs 1.4.4 async-timeout 4.0.3 attributedict 0.3.0 attrs 23.1.0 auto-gptq 0.4.2+cu121 autoawq 0.1.6 bitsandbytes 0.41.1 blessings 1.7 blinker 1.7.0 blis 0.7.11 cachetools 5.3.2 catalogue 2.0.10 certifi 2023.7.22 cffi 1.16.0 chardet 5.2.0 charset-normalizer 3.3.2 ci-info 0.3.0 click 8.1.7 cloudpathlib 0.16.0 codecov 2.1.13 colorama 0.4.6 coloredlogs 15.0.1 colour-runner 0.1.1 confection 0.1.4 configobj 5.0.8 configparser 6.0.0 contourpy 1.2.0 coverage 7.3.2 cramjam 2.7.0 cryptography 41.0.5 ctransformers 0.2.27+cu121 cycler 0.12.1 cymem 2.0.8 dataclasses-json 0.6.1 DataProperty 1.0.1 datasets 2.14.6 deepdiff 6.6.1 dill 0.3.7 diskcache 5.6.3 distlib 0.3.7 distro 1.8.0 docker-pycreds 0.4.0 einops 0.7.0 etelemetry 0.3.1 exceptiongroup 1.1.3 exllama 0.0.18+cu121 exllamav2 0.0.7+cu121 faiss-gpu 1.7.2 fastapi 0.104.1 fastparquet 2023.10.1 ffmpy 0.3.1 filelock 3.13.1 fitz 0.0.1.dev2 FlagEmbedding 1.1.5 flash-attn 2.3.2 fonttools 4.44.0 frontend 0.0.3 frozenlist 1.4.0 fsspec 2023.10.0 future 0.18.3 gitdb 4.0.11 GitPython 3.1.40 google-auth 2.23.4 google-auth-oauthlib 1.1.0 gptq-for-llama 0.1.1+cu121 gradio 3.50.2 gradio_client 0.6.1 greenlet 3.0.1 grpcio 1.59.2 h11 0.14.0 httpcore 1.0.1 httplib2 0.22.0 httpx 0.25.1 huggingface-hub 0.17.3 humanfriendly 10.0 idna 3.4 importlib-metadata 6.8.0 importlib-resources 6.1.1 inspecta 0.1.3 InstructorEmbedding 1.0.1 isodate 0.6.1 itsdangerous 2.1.2 Jinja2 3.1.2 joblib 1.3.2 jsonlines 4.0.0 jsonpatch 1.33 jsonpointer 2.4 jsonschema 4.19.2 jsonschema-specifications 2023.7.1 kiwisolver 1.4.5 langchain 0.0.331 langcodes 3.3.0 langsmith 0.0.60 llama_cpp_python 0.2.11 lm-eval 0.3.0 looseversion 1.3.0 lxml 4.9.3 Markdown 3.5.1 markdown-it-py 3.0.0 MarkupSafe 2.1.3 marshmallow 3.20.1 matplotlib 3.8.1 mbstrdecoder 1.1.3 mdurl 0.1.2 mpmath 1.3.0 multidict 6.0.4 multiprocess 0.70.15 murmurhash 1.0.10 mypy-extensions 1.0.0 networkx 3.2.1 nibabel 5.1.0 ninja 1.11.1.1 nipype 1.8.6 nltk 3.8.1 numexpr 2.8.7 numpy 1.24.4 nvidia-cublas-cu12 12.1.3.1 nvidia-cuda-cupti-cu12 12.1.105 nvidia-cuda-nvrtc-cu12 12.1.105 nvidia-cuda-runtime-cu12 12.1.105 nvidia-cudnn-cu12 8.9.2.26 nvidia-cufft-cu12 11.0.2.54 nvidia-curand-cu12 10.3.2.106 nvidia-cusolver-cu12 11.4.5.107 nvidia-cusparse-cu12 12.1.0.106 nvidia-nccl-cu12 2.18.1 nvidia-nvjitlink-cu12 12.3.52 nvidia-nvtx-cu12 12.1.105 oauthlib 3.2.2 openai 1.1.1 optimum 1.13.1 ordered-set 4.1.0 orjson 3.9.10 packaging 23.2 pandas 2.1.2 pathlib 1.0.1 pathtools 0.1.2 pathvalidate 3.2.0 pdf2image 1.16.3 pdfminer.six 20221105 pdfplumber 0.10.3 peft 0.5.0 Pillow 10.1.0 pip 23.3.1 platformdirs 3.11.0 pluggy 1.3.0 portalocker 2.8.2 preshed 3.0.9 protobuf 4.23.4 prov 2.0.0 psutil 5.9.6 py-cpuinfo 9.0.0 pyarrow 14.0.0 pyasn1 0.5.0 pyasn1-modules 0.3.0 pybind11 2.11.1 pycountry 22.3.5 pycparser 2.21 pydantic 2.4.2 pydantic_core 2.10.1 pydeck 0.8.1b0 pydot 1.4.2 pydub 0.25.1 Pygments 2.16.1 pyparsing 3.1.1 pypdf 3.17.0 pypdfium2 4.23.1 pyproject-api 1.6.1 pytablewriter 1.2.0 python-dateutil 2.8.2 python-multipart 0.0.6 pytz 2023.3.post1 pyxnat 1.6 PyYAML 6.0.1 rdflib 7.0.0 referencing 0.30.2 regex 2023.10.3 requests 2.31.0 requests-oauthlib 1.3.1 rich 13.6.0 rootpath 0.1.1 rouge 1.0.1 rouge-score 0.1.2 rpds-py 0.12.0 rsa 4.9 sacrebleu 1.5.0 safetensors 0.4.0 scikit-learn 1.3.2 scipy 1.11.3 semantic-version 2.10.0 sentence-transformers 2.2.2 sentencepiece 0.1.99 sentry-sdk 1.34.0 setproctitle 1.3.3 setuptools 68.2.2 simplejson 3.19.2 six 1.16.0 smart-open 6.4.0 smmap 5.0.1 sniffio 1.3.0 spacy 3.7.2 spacy-legacy 3.0.12 spacy-llm 0.6.4 spacy-loggers 1.0.5 SQLAlchemy 2.0.23 sqlitedict 2.1.0 srsly 2.4.8 starlette 0.27.0 streamlit 1.28.1 sympy 1.12 tabledata 1.3.3 tabulate 0.9.0 tcolorpy 0.1.4 tenacity 8.2.3 tensorboard 2.15.1 tensorboard-data-server 0.7.2 termcolor 2.3.0 texttable 1.7.0 thinc 8.2.1 threadpoolctl 3.2.0 tokenizers 0.14.1 toml 0.10.2 tomli 2.0.1 toolz 0.12.0 torch 2.1.0 torch-grammar 0.3.3 torchvision 0.16.0 tornado 6.3.3 tox 4.11.3 tqdm 4.66.1 tqdm-multiprocess 0.0.11 traits 6.3.2 transformers 4.35.0 triton 2.1.0 typepy 1.3.2 typer 0.9.0 typing_extensions 4.8.0 typing-inspect 0.9.0 tzdata 2023.3 tzlocal 5.2 urllib3 2.0.7 uvicorn 0.24.0.post1 validators 0.22.0 virtualenv 20.24.6 wandb 0.15.12 wasabi 1.1.2 watchdog 3.0.0 weasel 0.3.4 websockets 11.0.3 Werkzeug 3.0.1 wheel 0.41.3 xxhash 3.4.1 yarl 1.9.2 zipp 3.17.0 zstandard 0.22.0

adrianeboyd commented 11 months ago

Rename your script spacy.py to a name that doesn't conflict with any module names.

Python appears to be trying to import your spacy.py file as the spacy module (since local modules have priority for python imports).