I am getting such an error in the keras codes ,wrote in pycharm.Tried the solutions on the internet but I couldn't find a solution. Do you have any suggestions?
Error Image
Pip List
Please install the tensorflow and pillow using pip install tensorflow and pip install pillow then do a little changes as below while importing libraries to fix this error:
import numpy as np
from PIL import Image
from tensorflow import keras
from tensorflow.keras.applications import resnet50
from tensorflow.keras.preprocessing import image
Note: Please mention the error code in your question not in the form of a screenshot which will be easy to replicate the issue.
Related
I recently updated pytorch and torchtext from anaconda, in order to run this tutorial from the torchtext website, but it seems that my installation of torchtext has been broken. Everytime that I try import torchtext I get the following error:
ImportError: cannot import name '_log_class_usage' from 'torchtext.utils' (c:\Users\ferdi\anaconda3\lib\site-packages\torchtext\utils.py)
Uninstalling torchtext then reinstalling with conda install -c pytorch torchtext does not help.
Does anybody have an idea for how to solve it? My torch version is 1.13.0.
I am getting ModuleNotFoundError when I try to import tensorflow_io.
I tried to fix the error as described in ModuleNotFoundError: No module named 'tensorflow_io' but it didn't work with me
I did the following and I was able to have the module imported in my machine,
pip install tensorflow
pip install tensorflow_io
then in a file.py you can import them
import tensorflow as tf
import tensorflow_io as tfio
I figure you need the tensorflow module installed if you want to use the tensorflow_io.
Running this:
import torchvision
import tensorflow
Produces the error:
SystemError: google/protobuf/pyext/descriptor.cc:354: bad argument to internal function
However, swapping the order of the imports does not cause the error:
import tensorflow
import torchvision
Why is this happening?
Version info:
tensorflow-gpu=1.15.0
torchvision==0.5.0
Try reinstalling torchvision.
I have opened a ticket on tensorflow. My guess is that the order in which you install torchvision matters:
The fix is either to reinstall torchvision or to always import tensorflow first, as shown above. The issue is difficult to reproduce since fresh install fixes things. Perhaps it is related to the order in which packages are installed -- perhaps torchvision is somehow targeting older tensorflow-related libraries... and updating it again fixes this.
This fix:
import tensorflow # BEFORE all other imports
import torchvision
It works for me.
Source: https://github.com/tensorflow/tensorflow/issues/48797
I'm having an issue with my tensorflow on windows 10 (python 3.7, tf 2.1.0, keras 2.3.1, pillow 7.1.1). I had some code I wrote on an osx machine and was porting over to windows. I am using conda envs and have all the necessary packages installed (tensorflow, keras, pillow, opencv, etc) but I am getting the following error
Traceback (most recent call last):
...
"...\venv\lib\site-packages\keras_preprocessing\image\utils.py", line 108, in load_img
raise ImportError('Could not import PIL.Image. '
ImportError: Could not import PIL.Image. The use of `load_img` requires PIL.
I have tried reinstalling pillow, tensorflow, keras, creating a new environment, installing with pip and repeated this in about every location I can think of but this issue remains persistent. Any help would be greatly appreciated.
Thank you
One solution that might work for your case:
First, you need to : pip install pillow (uninstall + reinstall / upgrade it it's the case)
Second, you need to change your imports in this way:
from IPython.display import display
from PIL import Image
This solution can be found in the following thread:
ImportError: Could not import the Python Imaging Library (PIL) required to load image files on tensorflow
I am trying MNIST dataset, however, the code
import time
import mdp
import mnistdigits
results in the following error:
ModuleNotFoundError: No module named 'mnistdigits'
Where I can install this module using pip?
python-mnist 0.3 showed up when I googled "install mnist using pip"
pip install python-mnist