I am working on an image compression module, for that I want use jpeg library, but when I am importing it I am getting the following error.
"" import jpeg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named jpeg
this was happening after i installed the libjpeg library also, I want use jpeg in python image compression, so can any tell me resolve the problem , how to install jpeg in ubuntu
and help me solve the error .
I believe it's recommended to use the Python Imaging Library as the jpeg module is deprecated since python 3.0. So the module you need to import:
import Image
If you still get an import error then try:
sudo apt-get install python-imaging
Documentation can be found here: http://effbot.org/imagingbook/introduction.htm
and there are some jpeg examples on that page.
I believe the problem is that you're trying to use the jpeg module in an unsupported platform. According to the documentation it's only supported in IRIX, so if you try to import it in a different platform, then you'll get the ImportError exception.
Related
I currently have opencv-python 4.5.3.56 installed and running in Python 3.8. However, whenever I try to use the library, I get the error:
Traceback (most recent call last):
File "c:/Users/ryck5/Documents/FA2021/ECEG301/camerademo/color_detection.py", line 108, in <module>
dj.open_camera()
cap = opencv.VideoCapture(0)
AttributeError: module 'opencv' has no attribute 'VideoCapture'
I also tried print(opencv.__version__), but that gave me the same error, just with version instead of VideoCapture. I've tried uninstalling and reinstalling opencv countless times, using the opencv-contrib-python library instead, but nothing has worked. Any help would be much appreciated!
opencv library is used as cv2 namespace in python environment. Most probably you have installed python-opencv and using it.
Try:
import cv2 and then use cv2.VideoCapture().
Also, this is why opencv.__version__ is giving you error as there is no opencv object or library here. Try cv2.__version__.
I am trying to do some studies and automation related to image metadata.
from PIL import Image
Image.open("/Users/carlo/Desktop/JPEG 2/DSC_0393.jpeg")
This is the error that I am receiving:
Traceback (most recent call last):
File "/Users/carlo/PythonProjects/ImageMetaData_00/main.py", line 1, in <module>
from PIL import Image
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/Image.py", line 114, in <module>
from . import _imaging as core
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so: mach-o, but wrong architecture
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so: mach-o, but wrong architecture
I am using Python 3.10, not sure what I am missing. Thanks!
It’s telling you you’ve got a version of PIL downloaded/installed, but it’s not suitable for your computer architecture. You’re probably on an M1 Mac instead of an Intel one. To fix this try these:
pip3 install wheel
pip3 install --no-cache-dir pillow
If that doesn't work, you can try to switch to using python via Rosetta.
Go to the Application folder -> Right-click on Terminal App -> Get Info
Tick Open with Rosetta option.
Also try reinstalling it: pip3 install pillow.
If all else fails try downgrading python and see if anything clicks.
This is an error that I've seen in several different places but none of the listed solutions have worked for me.
I'm trying to use opencv but when I import the module I get the following error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
I have tried installing opencv from a pre-downloaded package, my computer has the current windows media pack and I jave run the module the depends without it listing any dependecy errors, I'm not sure what else to try at this point.
Edit: I have also tried installing opencv-contrib-python to no avail.
Let me know if you have any suggestions.
I had faced a similar issue and I solved it using:
pip install opencv-contrib-python
I updated from python 3.7.3 to python 3.7.6 and it fixed the problem. Worth a shot if you have the same issue.
A similar problem with the python gdal module Gdal will not import after several installs (Mac OSX) was solved by modifying my shell profile to ensure MacPorts-installed ports are found, and then using sudo port select python python27.
But this time it's every module in my graphics folder that deals with tiff and png reading and writing that will not import:
tiff #3.9.5 graphics/tiff
pngpp #0.2.3 graphics/pngpp
libgeotiff #1.3.0 graphics/libgeotiff
Again, when I run python to import either module I get the similar response:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named png
What am I doing wrong?
For most Python packages, MacPorts has separate ports available for each supported Python version. For example, if you are trying to use PIL (the Python Imaging Library), you need to install the 2.7 version of that port:
sudo port install py27-pil
That will also install the MacPorts version of Python 2.7, if you don't already have it installed. It is located at /opt/local/bin/python2.7.
I've spent the day trying to get the h5py module of python working, but without success. I've installed HDF5 shared libraries, followed the instructions I could find on the web to get it right. But it doesn't work, below is the error message I get when trying to import the module into python. I tried installing through MacPorts too but again it wouldnt work.
I'm using Python27 32 bits (had too for another module, and thus installed the i386 HDF5 library... if that's right?)
Any help very welcome !
Thank you !
import h5py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/__init__.py", line 1, in <module>
from h5py import _errors
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_errors.so, 2): Symbol not found: _H5E_ALREADYEXISTS_g
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_errors.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_errors.so
Check that you are not inside the h5py installation directory.
My advice, if you can, install h5py using Anaconda Distribution Open Data Science Core.