Skip to content

most likely due to a circular import #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
minkai95 opened this issue Apr 14, 2023 · 3 comments
Closed

most likely due to a circular import #106

minkai95 opened this issue Apr 14, 2023 · 3 comments

Comments

@minkai95
Copy link

minkai95 commented Apr 14, 2023

Hi, The following problem occurred when i try to run python case.
Could you help me check it? thank you.

I have installed tiktoken package.
Here is my Python code.
import tiktoken
enc = tiktoken.get_encoding("cl100k_base")
assert enc.decode(enc.encode("hello world")) == "hello world"
enc = tiktoken.encoding_for_model("gpt-4")

When I run it, console report an error as follows:
Traceback (most recent call last):
File "/PycharmProjects/pythonProjectStudy/tokencount/tiktoken.py", line 1, in <module>
import tiktoken
File "/PycharmProjects/pythonProjectStudy/tokencount/tiktoken.py", line 2, in <module>
enc = tiktoken.get_encoding("cl100k_base")
AttributeError: partially initialized module 'tiktoken' has no attribute 'get_encoding' (most likely due to a circular import)
Thank you.

@Subhamp7
Copy link

Hi @minkai95,

This is a general Python error, I can see the Python file you created is named "tiktoken.py".
I would recommend you rename it with something else rather than using the same library name.
For example rename "tiktoken.py" as "tiktoken_test.py".

Thanks.

@minkai95
Copy link
Author

oooo, I made an extremely foolish question.
Thank you very much. @Subhamp7

@hauntsaninja
Copy link
Collaborator

Thanks Subhamp7!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants