-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
ImportError: cannot import name '_imaging' #4982
Comments
Hi. Could you provide some detail on how you installed Pillow? |
I installed it with |
Knowing the specific commands that you've run could be helpful, and the output of those commands as well ideally. Two ideas
|
I played around a bit to find out more about the issue. First, I started python in a standard UNIX-terminal.
Next, I confirmed that it is still that counterintuitive that the "pillow" package needs to imported with "import PIL" in python.
So why is that?
Next, start python again in the terminal and try to import pillow.
Let's find out where it is with the magical "find"-command:
Try again to import the pillow package in a python environment.
Since it is not installed anymore on the system..
.. the next thing to do is removing the remainders directly:
FINAL CHECK for "import PIL".
This also shows up, when executing the initial command:
Next, I'm going to upgrade pip, as required
Then, I'm reinstalling the pillow package:
Now, testing again the intially failed command, which will unfortunately fail again for the same reason:
Yet and again, it's possible to import the PIL package and its Image-script flawlessly in a standard python environment
Checking again where the pillow packages are installed.
By and large, the same question remains as I initially posed: |
I think the fact that console python3 can import it successfully indicates that the problem isn't with your Pillow installation as such - I think img2pdf hasn't correctly packaged Pillow into /usr/bin/img2pdf |
Yes, this could be true. Thanks for your help. |
Hi, img2pdf author here. I'm not saying that this is a PIL bug but @AndreasLuckert just opened an issue against img2pdf and I do not see how this can possibly be a bug in img2pdf. Given this backtrace:
All that img2pdf does is to do a To me this looks more like a wrong installation of PIL, no? |
I strongly suspect that there is something wrong with your setup. I created a ubuntu 18.04 chroot using To test installation via pip I created a chroot of ubuntu 20.04 using debootstrap and then ran
And then tried converting some images:
And |
Hi. Ok, @AndreasLuckert, could you try these commands.
If both of those pass, but The output from |
There are two ways to install img2pdf on ubuntu 18.04. Since @AndreasLuckert has As I showed above, both methods of installing img2pdf (via apt and via pip) work just fine on a fresh Ubuntu installation. So what we are now actually trying to figure out here is what is wrong in the setup of @AndreasLuckert and not what is wrong in either img2pdf or PIL. |
I tried to execute both commands and they worked successfully:
The command revealing the system paths you suggested has the following output:
Next, checking where
Check also whether it can be installed via pip:
Finally, print out all files and directories related to
I hope this helps in further diagnosis. |
You installed img2pdf via apt (as proven by it being located in |
A general tip: use A virtualenv (or similar) may also help isolate things. |
So should I uninstall |
Finally everything works like a charm! The problem was the installation with I uninstalled Now, the location is correct:
The final test, which worked out successfully:
|
What did you do?
I converted a PNG to a jp2-file via convert
sample.png -quality 0 sample.jp2
.Next, I wanted to convert the resulting jp2-file to a proper PDF:
img2pdf -o sample.pdf sample.jp2
What did you expect to happen?
The jp2-image should have been converted to a PDF via the command
img2pdf -o sample.pdf sample.jp2
.What actually happened?
The following error occurred:
What are your OS, Python and Pillow versions?
OS: Ubuntu 18.04
Python: Python 3.8.5 (default, Jul 22 2020, 18:54:26)
[GCC 5.4.0 20160609] on linux
Pillow:
Version: 7.2.0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Alex Clark (PIL Fork Author)
Author-email: aclark@python-pillow.org
License: HPND
Location: /home/linuxbrew/.linuxbrew/lib/python3.8/site-packages
Requires:
Required-by: scikit-image, matplotlib, imageio, geos, bokeh
The text was updated successfully, but these errors were encountered: