openai / openai-python

The official Python library for the OpenAI API
https://pypi.org/project/openai/
Apache License 2.0
23.08k stars 3.25k forks source link

ModuleNotFoundError: No module named 'jiter.jiter' when Importing openai Package #1864

Closed fedorowych closed 1 week ago

fedorowych commented 1 week ago

Confirm this is an issue with the Python library and not an underlying OpenAI API

Describe the bug

Description I'm encountering a ModuleNotFoundError when attempting to import the openai Python library. The error indicates that the jiter.jiter module is missing, preventing the import from succeeding.

Error Message plaintext Copy code ModuleNotFoundError: No module named 'jiter.jiter'

To Reproduce

Steps to Reproduce Set Up Virtual Environment:

bash Copy code python -m venv myenv_py311 myenv_py311\Scripts\activate # On Windows Install openai:

bash Copy code pip install openai==1.54.3 Also tried openai==1.53.0 with the same result. Install jiter from GitHub:

bash Copy code pip install git+https://github.com/openai/jiter.git Attempt to Import openai:

python Copy code import openai Result: Raises ModuleNotFoundError: No module named 'jiter.jiter' Additional Steps Taken:

Uninstalled External jiter: bash Copy code pip uninstall jiter Reinstalled openai: bash Copy code pip uninstall openai pip install openai Verified Package Structure: Checked the jiter package directory; jiter.py is present after installing from GitHub. Created a Fresh Virtual Environment: Issue persists even in a new environment.

Code snippets

(myenv) D:\Resume Project>python -c "import openai"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import openai
  File "D:\Resume Project\myenv\Lib\site-packages\openai\__init__.py", line 11, in <module>
    from ._client import Client, OpenAI, Stream, Timeout, Transport, AsyncClient, AsyncOpenAI, AsyncStream, RequestOptions
  File "D:\Resume Project\myenv\Lib\site-packages\openai\_client.py", line 11, in <module>
    from . import resources, _exceptions
  File "D:\Resume Project\myenv\Lib\site-packages\openai\resources\__init__.py", line 3, in <module>
    from .beta import (
    ...<6 lines>...
    )
  File "D:\Resume Project\myenv\Lib\site-packages\openai\resources\beta\__init__.py", line 3, in <module>
    from .beta import (
    ...<6 lines>...
    )
  File "D:\Resume Project\myenv\Lib\site-packages\openai\resources\beta\beta.py", line 14, in <module>
    from .chat.chat import Chat, AsyncChat
  File "D:\Resume Project\myenv\Lib\site-packages\openai\resources\beta\chat\__init__.py", line 3, in <module>
    from .chat import Chat, AsyncChat
  File "D:\Resume Project\myenv\Lib\site-packages\openai\resources\beta\chat\chat.py", line 6, in <module>
    from .completions import Completions, AsyncCompletions
  File "D:\Resume Project\myenv\Lib\site-packages\openai\resources\beta\chat\completions.py", line 27, in <module>
    from ....lib.streaming.chat import ChatCompletionStreamManager, AsyncChatCompletionStreamManager
  File "D:\Resume Project\myenv\Lib\site-packages\openai\lib\streaming\chat\__init__.py", line 21, in <module>
    from ._completions import (
    ...<4 lines>...
    )
  File "D:\Resume Project\myenv\Lib\site-packages\openai\lib\streaming\chat\_completions.py", line 8, in <module>
    from jiter import from_json
  File "D:\Resume Project\myenv\Lib\site-packages\jiter\__init__.py", line 1, in <module>
    from .jiter import *
ModuleNotFoundError: No module named 'jiter.jiter'

OS

Windows 11

Python version

Python 3.13

Library version

both OpenAI 1.54. 3 AND 1.53.0

RobertCraigie commented 1 week ago

Looks like the jiter install is broken, have you tried reinstalling it?

fedorowych commented 1 week ago

Yes, I have reinstalled it many, many times.

On Tuesday, November 12, 2024 at 05:29:50 AM MST, Robert Craigie ***@***.***> wrote:  

Looks like the jiter install is broken, have you tried reinstalling it?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

RobertCraigie commented 1 week ago

Okay, unfortunately there's not much we can do. I recommend asking for help from the pydantic team https://github.com/pydantic/jiter

fedorowych commented 1 week ago

 Reinstall always resulted with the same error. The init.py program does not include jiter.py. My research indicates that OpenAI 1.53 is not dependent on Jiter so I am trying that and that instead of using Python 3.13, Python version3.11 is proven to be Stabe. I'm trying that too. 

Ther was also mention that OpenAI 1.54.3 may be using jiter internally within OpenAI and is confused with its external usage. The bottom line is, however, jiter.py is not included in the init.py program. I am new to this so please forgive any misinterpretations, errors or omissions I may have made but so far I've spent2 days and over 20 hours trying to get this work both with Gpt-4-turbo and Cursor.

On Tuesday, November 12, 2024 at 05:29:50 AM MST, Robert Craigie ***@***.***> wrote:  

Looks like the jiter install is broken, have you tried reinstalling it?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

fedorowych commented 1 week ago

Sorry, I'm new to OpenAI etc. I've redirected the issue to https://github.com/pydantic/jiter