snowby666 / poe-api-wrapper

👾 A Python API wrapper for Poe.com. With this, you will have free access to GPT-4, Claude, Llama, Gemini, Mistral and more! 🚀
https://pypi.org/project/poe-api-wrapper/
GNU General Public License v3.0
953 stars 111 forks source link

Dependency error? #202

Open github-0-searcher opened 1 month ago

github-0-searcher commented 1 month ago

Hi just found out this repo. Nice work!

I am trying to install it in a new virtual env with

pip install -U poe-api-wrapper[proxy]

But there seems to be a dependency error with rich ...

finally i am either getting 1.3.6 of poe or just failed to import poeserver

ImportError: cannot import name 'PoeServer' from 'poe_api_wrapper'

I tried with python 3.11 and 3.9 this problem still exists.

github-0-searcher commented 1 month ago

update: I am still getting import error even with installed old 1.3.6

jishux2 commented 1 month ago

I've encountered this issue before.

The version of poe-api-wrapper doesn't really matter here since the package is imported directly from the current directory. For the ImportError you're experiencing, try installing nltk:

pip install nltk

This fixed the same issue for me.

github-0-searcher commented 4 weeks ago

Hi! Many thanks for your timely reply!

I am still getting this import error even with nltk installed.

To be more precise, I am with:

OS: windows 11 Python: 3.11.4 or 3.10.10

The installation problem still exists.

When tried to install with

pip install -U "poe-api-wrapper[proxy]"

instead of the up-to-date version, I finally get

Successfully installed Faker-15.3.4 aiohappyeyeballs-2.4.3 aiohttp-3.10.10 aiohttp-proxy-0.1.2 aiosignal-1.3.1 anyio-4.6.2.post1 attrs-24.2.0 ballyregan-1.0.6 beautifulsoup4-4.12.3 bs4-0.0.1 certifi-2024.8.30 charset-normalizer-3.4.0 click-8.1.7 colorama-0.4.6 commonmark-0.9.1 frozenlist-1.4.1 h11-0.14.0 html5lib-1.1 httpcore-1.0.6 httpx-0.27.2 idna-3.10 loguru-0.6.0 lxml-4.9.4 multidict-6.1.0 numpy-2.1.2 pandas-1.5.3 poe-api-wrapper-1.3.6 prettytable-3.11.0 propcache-0.2.0 pydantic-1.10.18 pygments-2.18.0 python-dateutil-2.9.0.post0 pytz-2024.2 requests-2.32.3 requests-toolbelt-1.0.0 rich-12.6.0 shellingham-1.5.4 six-1.16.0 sniffio-1.3.1 soupsieve-2.6 strenum-0.4.15 style-1.1.0 typer-0.6.1 typing-extensions-4.12.2 update-0.0.1 urllib3-2.2.3 wcwidth-0.2.13 webencodings-0.5.1 websocket-client-1.8.0 win32-setctime-1.1.0 yarl-1.15.5

Then i have the import error

>>> from poe_api_wrapper import PoeServer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'PoeServer' from 'poe_api_wrapper' (C:\Users\xxx\Envs\poe\Lib\site-packages\poe_api_wrapper\__init__.py)

This problem also exists in WSL Ubuntu with python 3.10.12

jishux2 commented 4 weeks ago

Thanks for sharing this information - I think I can see where the issue lies. You're working in the Python REPL outside of the project directory. In this case, Python searches for modules in your virtual environment, where poe_api_wrapper is installed as version 1.3.6. Taking a look at its __init__.py:

from .api import PoeApi
from .example import PoeExample

As shown above, the PoeServer class isn't exported in this version.

Regarding the dependency issues you mentioned, it seems the proxy extra's requirement for ballyregan is causing some conflicts. Try installing the dependencies in this order:

pip install ballyregan
pip install -U poe-api-wrapper
pip install numpy==1.26.4  # ballyregan affects numpy version, need to revert to older version

This should get you set up with the latest version of poe-api-wrapper and all its dependencies properly configured.

Don't worry about nltk for now - you can always add it to your environment later if you run into any NLTK-related issues.

Update: I apologize for the error in my previous response. To use the server functionality, you should actually install the package with the llm extra like this: pip install -U 'poe-api-wrapper[llm]'. This is actually mentioned in the Quick Setup section of the README.md. With this correction, everything should work as expected.