cannot import module imageio in python3 - python-3.x

Using python3, I am unable to import the imageio module into my python program, which I need, as I try to animate a list of PNG images I have. Thus far I have tried:
"pip3 install imageio" both running as myself and as root. The install succeeded, but it still errors out as in the subject line. I suppose I could try "apt-get install (package name)", but need to determine the package_name.
Any ideas more than welcome - TIA.

Try importing the last version.
import imageio.v3 as iio
im = iio.imread('imageio:chelsea.png')
print(im.shape) # (300, 451, 3)
ref https://imageio.readthedocs.io/en/stable/examples.html

Related

XGBoost module not found in site-packages. Imports but doesn't work. (mac OS)

I was able to install xgboost on my mac and have it so that I can import the module without any errors. However I cannot use it. When I try to import XGBRegressor. I get the following error :
cannot import name 'XGBRegressor' from 'xgboost' (unknown location).
Some of the support for this type of problem says that there may be more than one xgboost location, and that python is selecting the incorrect xgboost, however I have not been able to find how to fix this problem.
When I print the xgboost.__file__ location, it returns 'None'. However I know its in the site-packages folder in my python path.
I have python 3.9
Maybe this.
conda install -c conda-forge xgboost=0.6a2
Then, restart Spyder and re-run!

Python: cannot import name 'rgb2gray' from 'skimage.color'

When I try:
>>> from skimage import io
I get at the end the following:
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated
In case you run into this error from inside a Jupyter Notebook, try restarting the kernel as suggested in this GitHub issue.
That solved the problem for me.
It looks like you haven't installed scikit-image package.
Try this on terminal:
pip install -U scikit-image
And then try importing like this:
from skimage import io
from skimage.color import rgb2gray
If you still got the error or you have installed the package previously,
try reinstalling the package first.
If it still don't resolve your issue, then try updating the following packages:
matplotlib, scipy, pil, numpy and six
However, try not to import all of the subpackages to improve loading time. You can however try something like:
from skimage import color
...
gray_img = color.rgb2gray(img)
If you still got errors, make sure that you are using the correct python kernel and dependent modules are updated and installed.
If that did not help either, then try Anaconda, it come with many pre-installed packages.
Leave a comment if you still have a problem :)
three ways to convert RGB2Gray:
opencv:
import cv2
img=cv2.imread("file.jpg",0) [enter link description here][1]
or you can do this:
img=cv2.imread("file.jpg")
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.COLOR_BGR2GRAY beacause it reads BGR mode.
another methods you can look this link:
enter link description here
It happened to me once when I import skimage using env conda on Jupyter. I installed by pip or conda in env, that error happened. However, after restart the Jupyter, it worked.

Import error, there is no module named numpy, but it says that it is installed?

So I trying to install and run from MSFT the cntk, you know, just for fun. Anyway, I keep getting this error which says:
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Now I have looked around here a little and I found a post saying that I needed to install the latest version of NumPy, but when I go to do that, I get back this:
Requirement already satisfied: NumPy in c:\users\username\appdata\local\continuum\anaconda3\envs\cntk-py34\lib\site-packages
SO I really have no idea what is going on here.
Anyway, thanks in advance.
Is your IDE linked to Anaconda env? If you open up the Anaconda prompt and import numpy do you get the same error?
You probably have an environment outside of Anaconda which does not have numpy installed.
In my case, I was executing [filename].py from the Anaconda prompt as I would a batch file and was getting this error. I confirmed numpy was install by executing pip list.
Funning python and passing the script file name as an argument, eg python [filename].py, correctly imported the numpy module and executed the script without error.

issue plotting .cap files ScaPy Python3

After reading .cap file using rdpcap successfully, I've been trying to use the function pdfdump but it keeps giving me an error:
"AttributeError: 'SingleTexRunner' object has no attribute 'texoutput' "
here's my code:
from scapy.all import *
import pyx
a = rdpcap("the file path..")
a.pdfdump("output filename")
anyone got an idea how to solve this issue?
Use sudo apt-get install python3-pyx on Linux(Debian, Ubuntu...) to install pyx and its dependencies; installing pyx with pip install pyx is not enough.
I'm using Python 3.6.0
I've installed scapy with:
pip3 install scapy-python3
Using wireshark 2.2.3, I saved a dump using the default file format which is .pcapng
I've used the same code as you :
from scapy.all import *
import pyx
a = rdpcap("test.pcapng")
a.pdfdump("test.pdf")
and I obtain a valid pdf.
Don't run scapy (if you use the command line) or your script as root. This fixed it for me.

ImportError: cannot import name '_imagingtk'

I am using Anaconda with python 3.4 and I am not able to get all the pillow packages I need I am afraid on Windows 8.1.
I installed pillow via the Anaconda console with:
pip install pillow
which lead to:
The following packages will be UPDATED:
conda: 3.10.0-py34_0 --> 3.10.1-py34_0
conda-env: 2.1.3-py34_0 --> 2.1.4-py34_0
pillow: 2.7.0-py34_0 --> 2.8.1-py34_0
pip: 6.0.8-py34_0 --> 6.1.1-py34_0
setuptools: 14.3-py34_0 --> 15.0-py34_0
Now, in the spyder IPython console I start with: import tkinter, from PIL import ImageTk I have no errors here, but when executing ImageTk.PhotoImage(file='a.jpg') I receive an error, telling me: ImportError: cannot import name '_imagingtk'
What did I miss?
I know this is not a complete answer, but I have had the same problem and spent a day trying to figure it out...
Here is a small subset of things I tried yesterday to the best of my weak memory...
-Tried upgrating to the latest Python environment using anaconda (tip: you can create one using
conda update conda
conda update anaconda
(I think that's it, but may have tried to make sure for key packages explicitly etc.)
-Tried using Python 3.3 environment using anaconda (tip: you can create one using
conda update conda
conda create -n py33 python=3.3 anaconda
activate py33
-Tried using PythonWin instead of anaconda (that one took some time, had to install packets like numpy manually...)
-Tried updating / downgrading / installing/ uninstalling all kinds of different variations of Pillow, PIL, etc....
-Tried using opencv instead of PIL, though did not try to write my own components...
-Tried manually copying Tcl/tk and a few others to the lib directory as suggested by some posts
-Tried using import tkinter instead of Tkinter, using import Image vs. form PIL import Image (and in general taking Image from PIL, or opencv, or Tkinter) and a lot of other similar changes to the point it fell I was doing silly things
-...
At the end, I googled a few pages about GUIs in python, and now I am using wx... I had to run
conda install wxpython
and that was it. I have to say that after all this, I am presently surprised by how easy it was to make it work, here is a code example...
You need tcl/tk library.
Install them using apt-get
Do sudo apt-get install tk8.6-dev tcl8.6-dev
--Reference.

Resources