Forums

Error on Deployment But Not Locally

Hi,

I'm a bit confused. I'm having this openai error in pythonanywhere console. But the same virtualenv (same python 3.10) and repo is working locally and working on render.com.

So I'm guessing there is a specific case in pythonanywhere? How to go about this?

==============

   Traceback (most recent call last):
  File "/home/bentraje/bentraje-api/app.py", line 4, in <module>
    from openai import OpenAI
  File "/home/bentraje/.local/lib/python3.10/site-packages/openai/__init__.py", line 8, in <module>
    from . import types
  File "/home/bentraje/.local/lib/python3.10/site-packages/openai/types/__init__.py", line 5, in <module>
    from .batch import Batch as Batch
  File "/home/bentraje/.local/lib/python3.10/site-packages/openai/types/batch.py", line 7, in <module>
    from .._models import BaseModel
  File "/home/bentraje/.local/lib/python3.10/site-packages/openai/_models.py", line 736, in <module>
    class RootModel(GenericModel, Generic[_T]):
  File "pydantic/main.py", line 187, in pydantic.main.ModelMetaclass.__new__
  File "pydantic/typing.py", line 356, in pydantic.typing.resolve_annotations
  File "/usr/local/lib/python3.10/typing.py", line 327, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "/usr/local/lib/python3.10/typing.py", line 693, in _evaluate
    type_ = _type_check(
  File "/usr/local/lib/python3.10/typing.py", line 176, in _type_check
    raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Forward references must evaluate to types. Got ~_T.

I also double check that my local copy of openai and pydantic and the pythonanywhere version are the same

I guess the only thing that is different is that I have 3.10.10 in my local env/github repo but python anywhere 3.10.5.

Does this matter? I'm asking because I believe you can't install another python version in pythonanywhere. correct me if I'm wrong

I don't think this could be caused by a difference in the point release of Python. How have you installed pydantic? The paths in that traceback look a bit weird, I'd expect them to start with /home/bentraje/.local/lib/python3.10/site-packages/.