Closed pamelafox closed 11 months ago
@pamelafox It works fine on Python3.12 if you have a rust compiler.
If you're building it in Docker, make sure you add it to your path.
RUN apt-get -y install curl build-essential gcc make && curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
@JoshJarabek7 Many thanks for your input. However, if I use Python 3.11 it works like a charm.
Why is it suddenly causing trouble?
@junoriosity not sure. Could be a few things. More than likely it's because Python 3.12 removed setuptools, which helps build Python packages. You can still install it via pip if you need it if you want to try that before pip installing tiktoken. You can also try installing via binary in pip instead of downloading setuptools.
Another reason could be that tiktoken is written in Rust (not sure if it was before or not) for some speed gains solely for Python 3.12.
@JoshJarabek7 Essentially, my Dockerfile looks like this
FROM python:3.12-alpine
RUN pip install --upgrade pip && pip install setuptools==69.0.1
RUN pip install tiktoken==0.5.1
and I get the error
4.957 Building wheels for collected packages: tiktoken
4.958 Building wheel for tiktoken (pyproject.toml): started
5.269 Building wheel for tiktoken (pyproject.toml): finished with status 'error'
5.277 error: subprocess-exited-with-error
5.277
5.277 × Building wheel for tiktoken (pyproject.toml) did not run successfully.
5.277 │ exit code: 1
5.277 ╰─> [38 lines of output]
5.277 running bdist_wheel
5.277 running build
5.277 running build_py
5.277 creating build
5.277 creating build/lib.linux-x86_64-cpython-312
5.277 creating build/lib.linux-x86_64-cpython-312/tiktoken
5.277 copying tiktoken/__init__.py -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 copying tiktoken/model.py -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 copying tiktoken/registry.py -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 copying tiktoken/load.py -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 copying tiktoken/_educational.py -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 copying tiktoken/core.py -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 creating build/lib.linux-x86_64-cpython-312/tiktoken_ext
5.277 copying tiktoken_ext/openai_public.py -> build/lib.linux-x86_64-cpython-312/tiktoken_ext
5.277 running egg_info
5.277 writing tiktoken.egg-info/PKG-INFO
5.277 writing dependency_links to tiktoken.egg-info/dependency_links.txt
5.277 writing requirements to tiktoken.egg-info/requires.txt
5.277 writing top-level names to tiktoken.egg-info/top_level.txt
5.277 reading manifest file 'tiktoken.egg-info/SOURCES.txt'
5.277 reading manifest template 'MANIFEST.in'
5.277 warning: no files found matching 'Makefile'
5.277 adding license file 'LICENSE'
5.277 writing manifest file 'tiktoken.egg-info/SOURCES.txt'
5.277 copying tiktoken/py.typed -> build/lib.linux-x86_64-cpython-312/tiktoken
5.277 running build_ext
5.277 running build_rust
5.277 error: can't find Rust compiler
5.277
5.277 If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.
5.277
5.277 To update pip, run:
5.277
5.277 pip install --upgrade pip
5.277
5.277 and then retry package installation.
5.277
5.277 If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
5.277 [end of output]
5.277
5.277 note: This error originates from a subprocess, and is likely not a problem with pip.
5.278 ERROR: Failed building wheel for tiktoken
5.278 Failed to build tiktoken
5.278 ERROR: Could not build wheels for tiktoken, which is required to install pyproject.toml-based projects
------
failed to solve: process "/bin/sh -c pip install tiktoken==0.5.1" did not complete successfully: exit code: 1
Perhaps you have an idea how to overcome this. 😊
@JoshJarabek7 Thanks for the suggestion! We are using it an open source sample for developers on many systems (Mac/Linux/Windows) so we can't assume they'll have a Rust compiler. We eagerly await formal support via a built wheel.
tiktoken 0.5.2 ships Python 3.12 wheels :-)
python 3.12.4 tiktoken7.0 error
We are trying to install tiktoken in Python 3.12, but get an error:
Can 3.12 wheels be released?