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:
User$ img2pdf -o sample.pdf sample.jp2
Traceback (most recent call last):
File "/usr/bin/img2pdf", line 11, in <module>
load_entry_point('img2pdf==0.2.3', 'console_scripts', 'img2pdf')()
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 473, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2447, in load
return self.resolve()
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2453, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/img2pdf.py", line 24, in <module>
from PIL import Image
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/PIL/Image.py", line 94, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging'
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
I've already asked this question at the pillow-package GibHub-page to find out that the issue must lie in the img2pdf - installation
I see no such evidence in the issue you opened with Pillow. Can you clearly quote the part that proves that this is an issue with img2pdf?
All that img2pdf does here is to run from PIL import Image. There is nothing wrong with that statement -- how should your problem be fixed by img2pdf?
By Andreas on 2020-10-16T09:05:20.339Z
Thanks for your quick reply.
The question is then why it's possible to import the PIL package and its Image-script flawlessly in a standard python environment?
andylu@andylu-ThinkPad-Edge-E130:~/Desktop/Master_project/WWTP La Oliva/Top_view_of_WWTP$ python
Python 3.8.5 (default, Jul 22 2020, 18:54:26)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
# No error will be thrown here, but is thrown within the img2pdf - script
>>> from PIL import Image
>>> quit()
By josch on 2020-10-16T09:13:44.314Z
There can be many reasons. For example I notice that your python libraries are in /home/linuxbrew/.linuxbrew/. I suspect that you are mixing your environments in an incompatible manner. I suggest you try running img2pdf without linuxbrew in your PYTHONPATH.
*By Andreas on 2020-10-16T07:38:18.663Z*
### What did you do?
NOTE: I've already asked this question at the pillow-package GibHub-page to find out that the issue must lie in the img2pdf - installation:
https://github.com/python-pillow/Pillow/issues/4982
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:
```
User$ img2pdf -o sample.pdf sample.jp2
Traceback (most recent call last):
File "/usr/bin/img2pdf", line 11, in <module>
load_entry_point('img2pdf==0.2.3', 'console_scripts', 'img2pdf')()
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 473, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2447, in load
return self.resolve()
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2453, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/img2pdf.py", line 24, in <module>
from PIL import Image
File "/home/linuxbrew/.linuxbrew/lib/python3.8/site-packages/PIL/Image.py", line 94, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging'
```
### 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
<!--
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.
The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as Plone, Django, or Buildout, try to replicate the issue just using Pillow.
-->
---
*By josch on 2020-10-16T08:49:13.973Z*
---
> I've already asked this question at the pillow-package GibHub-page to find out that the issue must lie in the img2pdf - installation
I see no such evidence in the issue you opened with Pillow. Can you clearly quote the part that proves that this is an issue with img2pdf?
All that img2pdf does here is to run `from PIL import Image`. There is nothing wrong with that statement -- how should your problem be fixed by img2pdf?
---
*By Andreas on 2020-10-16T09:05:20.339Z*
---
Thanks for your quick reply.
The question is then why it's possible to import the PIL package and its Image-script flawlessly in a standard python environment?
```
andylu@andylu-ThinkPad-Edge-E130:~/Desktop/Master_project/WWTP La Oliva/Top_view_of_WWTP$ python
Python 3.8.5 (default, Jul 22 2020, 18:54:26)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
# No error will be thrown here, but is thrown within the img2pdf - script
>>> from PIL import Image
>>> quit()
```
---
*By josch on 2020-10-16T09:13:44.314Z*
---
There can be many reasons. For example I notice that your python libraries are in `/home/linuxbrew/.linuxbrew/`. I suspect that you are mixing your environments in an incompatible manner. I suggest you try running img2pdf without linuxbrew in your PYTHONPATH.
---
*By Andreas on 2020-10-16T12:35:11.357Z*
---
The problem was resolved, the details can be found under the following link:
https://github.com/python-pillow/Pillow/issues/4982#issuecomment-710017946
Thanks josch for your time and help.
---
*By Andreas on 2020-10-16T12:35:12.829Z*
---
Status changed to closed
By Andreas on 2020-10-16T07:38:18.663Z
What did you do?
NOTE: I've already asked this question at the pillow-package GibHub-page to find out that the issue must lie in the img2pdf - installation:
https://github.com/python-pillow/Pillow/issues/4982
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
By josch on 2020-10-16T08:49:13.973Z
I see no such evidence in the issue you opened with Pillow. Can you clearly quote the part that proves that this is an issue with img2pdf?
All that img2pdf does here is to run
from PIL import Image
. There is nothing wrong with that statement -- how should your problem be fixed by img2pdf?By Andreas on 2020-10-16T09:05:20.339Z
Thanks for your quick reply.
The question is then why it's possible to import the PIL package and its Image-script flawlessly in a standard python environment?
By josch on 2020-10-16T09:13:44.314Z
There can be many reasons. For example I notice that your python libraries are in
/home/linuxbrew/.linuxbrew/
. I suspect that you are mixing your environments in an incompatible manner. I suggest you try running img2pdf without linuxbrew in your PYTHONPATH.By Andreas on 2020-10-16T12:35:11.357Z
The problem was resolved, the details can be found under the following link:
https://github.com/python-pillow/Pillow/issues/4982#issuecomment-710017946
Thanks josch for your time and help.
By Andreas on 2020-10-16T12:35:12.829Z
Status changed to closed