RED lines under libraries names - python-imaging-library

I just finished downloading pillow library and when i came to pycharm and type " import PIL " still underlined by red, saying " no module named PIL ". i've checked on youtube how i bring pillow's functions i am correct its " import PIL " i've checked even on the site it makes me think im wrong i lost my self confidence cause i can't fix it im in the same position for 2 weeks help please
i beleived that maybe 3.10 vesrion of python doesn't match with pillow library so i deleted it and i've downloaded 3.9 and i don't know im confused im lost

Related

How can I fix the attribute error in VS code when the same code runs perfectly on colab?

I was running the PySINDy package and I kept on getting the module not found-error when I ran this:
pip install pysindy
import pysindy as ps
I fixed this by downgrading the Python in my VS code to 3.8.9. But I do get the following note:
note: This error originates from a subprocess, and is likely not a problem with pip.Note: you may need to restart the kernel to use updated packages.
I am now getting the attribute error when I run the following:
differentiation_method = ps.FiniteDifference(order=2)
Here's the error:
AttributeError: module 'pysindy' has no attribute 'differentiation'
Can someone please help me with this? (I successfully ran the entire code earlier on google colab and the online Jupyter, but I am unable to do it locally. I use MAC os and Jupyter via VS Code.)

Unity showing this error - Assets\Plugins\GitHub\Editor\UnityAPIWrapper.cs: error CS0103: The name 'UnityShim' does not exist in the current context

I am using Unity 2019.2.2f1 and my project was built a long time with Unity 2017,2018. Now it is showing this error which is not resolving.
This error is due to ARCore and some basic packages.
Steps to resolve:
Import ARCore SDK again.(Assets >> Import Packages >> Custom Packages)
Use Window > Package Manager to install the "Multiplayer HLAPI" and "XR Legacy Input Helpers" packages. If it was already installed try removing and then reinstalling it again.

PIL thinks every image I give it is corrupted

I'm trying to get an array of RGB values for a jpeg. Using the code
from PIL import Image
im = Image.open('lion.jpg')
pix = list(im.getdata())
gives the error
IOError: broken data stream when reading image file
The picture in the code is this one, which I got from google for testing:
but the code returns the same error for every picture I've tried, from a variety of sources (google, phone, etc...). When I push forward and load the image anyway, all the pixel values are black.
I've tried doing
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
but all that does is suppress the error; the pixel values are still black.
It seems other people have had this problem elsewhere, like here, but so far other solutions have failed me. Any suggestions?
I'm on Mac 10.10, with python 2.7.8. I first installed Pillow with pip, and then from the source. I have confirmed that libjpeg is installed.
I don't really have an answer, but I can give you the setup of mine for which this is working fine.
The following script:
from PIL import Image
if __name__ == '__main__':
im = Image.open('lion.jpg'))
pix = list(im.getdata())
print('The image has {} pixels'.format(len(pix)))
import PIL, sys
print('Using Python version {}'.format(sys.version))
print('Using PIL version {}'.format(PIL.VERSION))
print('Using Pillow version {}'.format(PIL.PILLOW_VERSION))
Gives as a result on my Macbook with OS X El Capitan (10.11.6):
The image has 1183000 pixels
Using Python version 3.5.1 |Continuum Analytics, Inc.| (default, Dec 7 2015, 11:24:55)
[GCC 4.2.1 (Apple Inc. build 5577)]
Using PIL version 1.1.7
Using Pillow version 3.1.0
Process finished with exit code 0

Error in images2gif.py with GlobalPalette

Getting an error when trying to convert sequence of jpgs to gifs. Can't seem to figure out how to add a palette, or if that's the actual problem. Was able to get gifs to load using the numpy arrays in the images2gif.py main.
import PIL
from PIL import Image
import StringIO
import images2gif
images = []
for frame in animation1.frames:
img_data = s3manager.get_file_as_string(frame.s3_filename)
image = Image.open(StringIO.StringIO(img_data))
images.append(image)
images2gif.writeGif('lala3.gif', images, duration=0.5, dither=0)
With this I get the following error:
"images2gif.py", line 436, in writeGifToFile
fp.write(globalPalette)
TypeError: must be string or buffer, not None
Not sure how to specify a palette for these jpgs. documentation unclear to me, and not even sure if that's the issue. help?
In images2gif.py change line 200:
for im in images:
palettes.append( getheader(im)[1] )
to
for im in images:
palettes.append(im.palette.getdata()[1])
images2gif author seems to be willing to drop support for pillow. See this thread :
https://code.google.com/p/visvis/issues/detail?id=81
From this thread too, i found a fixed version of that script, which works with me (with pillow 2.4). It is available here :
https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py and produces good quality gif with any kind of PNG (P mode too)
images2gif.py uses getheader function from PIL.GifImagePlugin to get the palettes.
For some reason, it doesn't work with image you read. Maybe the script doesn't really work if source images are not 'P' mode.
I installed PIL after Pillow and it started to work. Seems like both libraries are needed for some reason. Here is how to reinstall both:
pip uninstall PIL
pip uninstall Pillow
pip install Pillow
pip install PIL

MacOSX python error on import

Ive recently installed SimpleCV using the osX-Lion setup instructions in page https://github.com/ingenuitas/simplecv
Then I type python in Terminal and when I try the following I get an error.
import SimpleCV
Fatal Python error: (pygame parachute) Segmentation Fault
Abort trap: 6
However I get no errors when i try to import pygame myself. Any fix for this?
Thanks
Use and follow this instructions of the new repository, the you are using have this Alert messages.
THE SIMPLECV REPO HAS MOVED (As of 4/17/13)
Says the repository title.
WARNING: The REPO here is for legacy purposes only