rtoml icon indicating copy to clipboard operation
rtoml copied to clipboard

ImportError when using rtoml in `python:alpine` container

Open Bogay opened this issue 2 years ago • 0 comments

I encountered an error message while working within my python:alpine container:

Traceback (most recent call last):
  File "//example.py", line 2, in <module>
    import rtoml
  File "/usr/local/lib/python3.11/site-packages/rtoml/__init__.py", line 5, in <module>
    from . import _rtoml
ImportError: cannot import name '_rtoml' from partially initialized module 'rtoml' (most likely due to a circular import) (/usr/local/lib/python3.11/site-packages/rtoml/__init__.py)

It seems that this error is caused by using wrong wheel, if I compile rtoml from source then the error gone. To reproduce, you can run the following command sequence:

Create container:

docker run --rm -it python:alpine sh

Inside the container:

wget https://raw.githubusercontent.com/samuelcolvin/rtoml/main/example.py

# Install using the wheel
pip install rtoml
# This will get error
python example.py

# Alternatively, build from source
pip uninstall rtoml
apk add cargo
pip install rtoml --no-binary :all:

# This can be executed successfully
python example.py

Bogay avatar Aug 28 '23 16:08 Bogay