martinbenes1996/jpeglib

IndexError: list index out of range

Closed this issue · 9 comments

Thank the author for your work, but when I import jpeglib according to the tutorial, there seems to be a problem. I check that this is not a compilation environment problem. I want to see when you are free. Can you answer this question.Thank you!

图片
code:
图片

During handling of the above exception, another exception occurred:

图片

What are your available versions? You can list them with

import jpeglib
jpeglib.version.versions()

There are automatic unit tests that check availability of all the versions in a prebuilt wheel. How did you install the library? Did you build from the source or used a prebuilt version.

Well, I just "pip install jpeglib" and imported the package into the project according to the tutorial, and an error occurred. I can't execute the following statement.
图片

图片
I am not familiar with the use of this toolkit, or is there any other way to use it?thank you!

When installed, the package compiles all the libjpeg/turbo/mozjpeg versions (or installs precompiled wheel for acceleration, not always). On import, version 6b is automatically used. Your problem seems to be because 6b is not compiled. Maybe answering following could help me troubleshoot your issue and possibly fix it for other users if it is an actual bug.

  • Did the pip install went through flawlessly? Wasn't there any warning/error message? You can try reinstalling in a clean environment and take a screenshot.

  • Is the error really raised on import jpeglib? It is not clear from your screenshots. If you would want to set non-existing version, it fail on the same error. Please use notebook or interactive session for your screenshots.

  • Did you install the package from wheel or from source? You can see that in the pip install output and also by the speed (couple of seconds installing wheel vs. 5 minutes compilation from source).

Demonstration

Let me show you an example of running inside "clean" Docker environment.

docker run \
    -it --rm \
    -p 8888:8888 \
    jupyter/datascience-notebook:python-3.10 \
    python -m notebook

Next I run the example from the tutorial. You can also see my platform (just to check).

Screen Shot 2022-11-01 at 10 49 08

The image was correctly opened, I got both its DCT coefficients and the pixels.

Here are versions of libjpeg/libjpeg-turbo/mozjpeg that I can choose from.

Screen Shot 2022-11-01 at 10 49 46

Please add more details.

You can also check the internals of the installed package, which versions are present. You are looking for file cjpeglib_6b.abi3.so. Be careful, your path to the package is probably different, especially if you don't use conda like me.

$ ls /opt/miniconda3/envs/ml/lib/python3.10/site-packages/jpeglib/cjpeglib
cjpeglib_6b.abi3.so		cjpeglib_9e.abi3.so
cjpeglib_7.abi3.so		cjpeglib_mozjpeg101.abi3.so
cjpeglib_8.abi3.so		cjpeglib_mozjpeg201.abi3.so
cjpeglib_8a.abi3.so		cjpeglib_mozjpeg300.abi3.so
cjpeglib_8b.abi3.so		cjpeglib_mozjpeg403.abi3.so
cjpeglib_8c.abi3.so		cjpeglib_turbo120.abi3.so
cjpeglib_8d.abi3.so		cjpeglib_turbo130.abi3.so
cjpeglib_9.abi3.so		cjpeglib_turbo140.abi3.so
cjpeglib_9a.abi3.so		cjpeglib_turbo150.abi3.so
cjpeglib_9b.abi3.so		cjpeglib_turbo200.abi3.so
cjpeglib_9c.abi3.so		cjpeglib_turbo210.abi3.so
cjpeglib_9d.abi3.so
$

But at least, your issue is an indicator for me that the error message is not very self-explanatory. That's a good hint.

Thank you from my heart, sir. I want to extract the DCT coefficients of jpeg images as a step of data hiding, so I want to see whether there is open source code.

I used Pycharm platform in windows. The env is created by anaconda.

Yes, I have cleaned up the pip cache and downloaded it again.
This is the screenshoot that i use to pip install.
图片

This is the screenshoot that i just import install jpelib.But the result seems not good.
图片

Thank you very much for your reply. At the beginning, I just tried. I didn't expect you would reply to me.But when I see that your example can run, I will continue to check what the problem is. I guess it may be the environment.

You are installing a pre-built wheel for Windows. It could be something about the mismatch between Windows vs. Unix paths. The package might be looking in the wrong directory for the dynamic libraries or something similar. Good, I have a clue what to look for. I'll get back to this issue.

Also, I realized that CI is executed on Linux only. I might add more platforms later, including Windows, to spot such things.

Okay. The problem I found is in the package - on Windows there is a different naming convention for dynamic libraries. I am preparing a fix, in couple of days I plan to release a new version, I plan it to be there.

Sorry for inconvenience and thank you for you patience.

Just released version 0.11.4 which should solve your problem.

Wow, the problem has been solved.
This is the first time for me to contact the author through github. I am very honored and lucky to be able to use this tool and know you. Thank you very much for spending so much time and energy on a small problem.
I also learned from you the preciseness in dealing with problems, which is what I lack. I salute you and thank you again for your efforts!