nomic-ai / pygpt4all

Official supported Python bindings for llama.cpp + gpt4all
https://nomic-ai.github.io/pygpt4all/
MIT License
1.02k stars 162 forks source link

Error running example code #55

Closed GrahamboJangles closed 1 year ago

GrahamboJangles commented 1 year ago
Exception has occurred: ModuleNotFoundError
No module named 'pyllamacpp.model'; 'pyllamacpp' is not a package

Yes, I have pyllamacpp installed through pip.

abdeladim-s commented 1 year ago

hi @GrahamboJangles,

Could you please give more clarifications! If the package is installed properly, then it should be imported like any pip package!

GrahamboJangles commented 1 year ago

hi @GrahamboJangles,

Could you please give more clarifications! If the package is installed properly, then it should be imported like any pip package!

Thank you for your quick reply. I figured it should be that simple, but for some reason it's not. I even tried a venv virtual environment.

G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>activate.bat

(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>pip install pyllamacpp
Collecting pyllamacpp
  Using cached pyllamacpp-1.0.6-cp310-cp310-win_amd64.whl (191 kB)
Collecting streamlit
  Using cached streamlit-1.21.0-py2.py3-none-any.whl (9.7 MB)
Collecting sentencepiece
  Downloading sentencepiece-0.1.98-cp310-cp310-win_amd64.whl (977 kB)
     ---------------------------------------- 977.8/977.8 KB 7.7 MB/s eta 0:00:00
Collecting torch
  Downloading torch-2.0.0-cp310-cp310-win_amd64.whl (172.3 MB)
     ---------------------------------------- 172.3/172.3 MB 1.9 MB/s eta 0:00:00
...
...
...
...
  Downloading attrs-22.2.0-py3-none-any.whl (60 kB)
     ---------------------------------------- 60.0/60.0 KB ? eta 0:00:00
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0
  Using cached pyrsistent-0.19.3-cp310-cp310-win_amd64.whl (62 kB)
Collecting mdurl~=0.1
  Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Installing collected packages: sentencepiece, pytz, mpmath, zipp, watchdog, urllib3, tzdata, typing-extensions, tornado, toolz, toml, sympy, smmap, six, pyrsistent, pympler, pygments, protobuf, pillow, packaging, numpy, networkx, mdurl, MarkupSafe, idna, filelock, entrypoints, decorator, colorama, charset-normalizer, certifi, cachetools, blinker, attrs, validators, requests, pytz-deprecation-shim, python-dateutil, pyarrow, markdown-it-py, jsonschema, jinja2, importlib-metadata, gitdb, click, tzlocal, torch, rich, pydeck, pandas, gitpython, altair, streamlit, streamlit-ace, pyllamacpp
Successfully installed MarkupSafe-2.1.2 altair-4.2.2 attrs-22.2.0 blinker-1.6.2 cachetools-5.3.0 certifi-2022.12.7 charset-normalizer-3.1.0 click-8.1.3 colorama-0.4.6 decorator-5.1.1 entrypoints-0.4 filelock-3.11.0 gitdb-4.0.10 gitpython-3.1.31 idna-3.4 importlib-metadata-6.3.0 jinja2-3.1.2 jsonschema-4.17.3 markdown-it-py-2.2.0 mdurl-0.1.2 mpmath-1.3.0 networkx-3.1 numpy-1.24.2 packaging-23.1 pandas-1.5.3 pillow-9.5.0 protobuf-3.20.3 pyarrow-11.0.0 pydeck-0.8.0 pygments-2.15.0 pyllamacpp-1.0.6 pympler-1.0.1 pyrsistent-0.19.3 python-dateutil-2.8.2 pytz-2023.3 pytz-deprecation-shim-0.1.0.post0 requests-2.28.2 rich-13.3.4 sentencepiece-0.1.98 six-1.16.0 smmap-5.0.0 streamlit-1.21.0 streamlit-ace-0.1.1 sympy-1.11.1 toml-0.10.2 toolz-0.12.0 torch-2.0.0 tornado-6.2 typing-extensions-4.5.0 tzdata-2023.3 tzlocal-4.3 urllib3-1.26.15 validators-0.20.0 watchdog-3.0.0 zipp-3.15.0
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the 'G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\env\Scripts\python.exe -m pip install --upgrade pip' command.

(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>
(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>
(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>python "pyllamacpp 2.py"
Traceback (most recent call last):
  File "G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\pyllamacpp 2.py", line 1, in <module>
    from pyllamacpp.model import Model
  File "G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\pyllamacpp.py", line 1, in <module>
    from huggingface_hub import hf_hub_download
ModuleNotFoundError: No module named 'huggingface_hub'

(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>pip install huggingface_hub
Collecting huggingface_hub
  Using cached huggingface_hub-0.13.4-py3-none-any.whl (200 kB)
Requirement already satisfied: filelock in g:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\env\lib\site-packages (from huggingface_hub) (3.11.0)
Collecting tqdm>=4.42.1
  Downloading tqdm-4.65.0-py3-none-any.whl (77 kB)
...
...
...
...
Successfully installed huggingface_hub-0.13.4 pyyaml-6.0 tqdm-4.65.0
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the 'G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\env\Scripts\python.exe -m pip install --upgrade pip' command.

(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>pip install huggingface_hub
Requirement already satisfied: huggingface_hub in g:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\env\lib\site-packages (0.13.4)
...
...
...
...
Requirement already satisfied: certifi>=2017.4.17 in g:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\env\lib\site-packages (from requests->huggingface_hub) (2022.12.7)
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the 'G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\env\Scripts\python.exe -m pip install --upgrade pip' command.

(env) G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64>python "pyllamacpp 2.py"
Traceback (most recent call last):
  File "G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\pyllamacpp 2.py", line 1, in <module>
    from pyllamacpp.model import Model
  File "G:\llama\alpaca-bin-models\alpaca-win\llama-master-3e6e70d-bin-win-avx2-x64\pyllamacpp.py", line 2, in <module>
    from pyllamacpp.model import Model
ModuleNotFoundError: No module named 'pyllamacpp.model'; 'pyllamacpp' is not a package

and the example script:

from pyllamacpp.model import Model

def new_text_callback(text: str):
    print(text, end="", flush=True)

model = Model(ggml_model='./models/gpt4all-model.bin', n_ctx=512)
model.generate("Once upon a time, ", n_predict=55, new_text_callback=new_text_callback, n_threads=8)
abdeladim-s commented 1 year ago

@GrahamboJangles the filename you are using to write the script is the same as the package. Please modify the filename from pyllamacpp.py to a different name ?

GrahamboJangles commented 1 year ago

@GrahamboJangles the filename you are using to write the script is the same as the package. Please modify the filename from pyllamacpp.py to a different name ?

Ah yes I thought of that too. You can see I ran "pyllamacpp 2.py" and I even tried "test.py" and still got the same error... Something must be wrong with my setup though I'm sure.

Edit: it probably is because I have a file in the directory named pyllamacpp.py and that is causing the issue

abdeladim-s commented 1 year ago

@GrahamboJangles Yes that's probably is the issue.