Tiktoken package installed but unable to import

Hi guys,

I was trying to use the tiktoken package in my project and installed a 0.3.3 version to my current environment. However, every time I tried to import this package into my code, it always says that “no module named ‘tiktoken’”. Is anyone having the same issue?

Python? Installed by pip install openai?

pip must be run in the same userspace as the python installation. So that means if you installed Python with “for all users” in the system, you also need to run the command prompt “as administrator” where you run pip, to put the packages alongside that installation.

Tiktoken is up to 0.4.0.

Thank you for your reply!

I tried “pip install openai” (or “python3 -m pip install openai” in my case), but it’s still not working. In terms of the userspace issue, how can I check if they are running in the same userspace?

Also, I just uninstalled the previous version of tiktoken and installed the 0.4.0 version, but not working either. for your information, when I installed 0.4.0, I got the followingprompt:
“ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
openai-whisper 20230314 requires tiktoken==0.3.3, but you have tiktoken 0.4.0 which is incompatible.”
Does this have anything to do with the problem I’m having right now?

Thanks

I should have inquired more about the platform on which you are running, and the rights you have on it.

Openai requires Python 3.7.1 or greater, and you will get more issues when going to the bleeding edge newest releases in general. Stable = 3.9, or 3.8 if you need more OS backwards compatibility.

The dependency would be the need to also install the latest openai module 0.28 with pip install --upgrade openai, again in the same user environment as the python install. If you’ve mixed up user or administrator when installing python packages, you’ll have quite a mess of software.

You should just ask GPT-4: “Create an example in Python that uses tiktoken to do…${whatever}, and assume I don’t even have the package installed yet.” :star_struck:

a simple reason could be that you’ve created a virtual environment but not switched to it (or vice versa) so the packages are not available.

1 Like