Error : from PIL import Image - import

I want to create a wordcloud in Python 2.7 (in OS X Yosemite).
I install the package from but when I execute:
from PIL import Image
an error appears:
from PIL import _imaging as core
ImportError: dlopen(/Applications/anaconda/lib/python2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: libjpeg.8.dylib
Referenced from: /Applications/anaconda/lib/python2.7/site-packages/PIL/_imaging.so
Reason: image not found

Remember to install the prerequisites.
OS X Installation
We provide binaries for OS X in the form of Python Wheels. Alternatively you can compile Pillow from soure with XCode.
The easiest way to install external libraries is via Homebrew. After you install Homebrew, run:
$ brew install libtiff libjpeg webp little-cms2
Install Pillow with:
$ pip install Pillow

Related

Cannot install zlib system headers for python packages

When installing python packages with poetry on Catalina OS I get this error for Pillow 6.2.1
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Even after I installed zlib with homebrew and added the relevant lines for the zshrc profile
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
I use python 3.8.0 which matches with the Pillow version I am trying to install.
I don't know what else to do.

ModuleNotFoundError: No module named 'cartopy' when import SkewT from metpy.plots under Python3

When trying to import SkewT into my python3 code on a Mac (Mojave 10.14.6):
from metpy.plots import SkewT
I get the error:
ModuleNotFoundError: No module named 'cartopy'
pip3 install cartopy gives the output
Collecting cartopy
Downloading https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz (8.9MB)
|████████████████████████████████| 8.9MB 616kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Complete output from command /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpj50b1vfe:
ERROR: setup.py:171: UserWarning: Unable to determine GEOS version. Ensure you have 3.3.3 or later installed, or installation may fail.
'.'.join(str(v) for v in GEOS_MIN_VERSION), ))
Proj 4.9.0 must be installed.
----------------------------------------
ERROR: Command "/usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpj50b1vfe" failed with error code 1 in /private/tmp/pip-install-b5cu8485/cartopy
To start, I tried to install Proj and geos, but pip3 only lists version 0.1.0 for proj and 0.2.2 for geos. Before I get too far down this rabbit hole, I thought I'd see if anyone else has encountered this problem. Thanks!
So it looks like MetPy 0.10 accidentally picked up a hard dependency on CartoPy, which we did not really plan. You can track our resolution of that here.
CartoPy depends on a lot of compiled libraries that are not pip-installable unfortunately. Your best bet is to look at CartoPy's install instructions. If you're using Anaconda or Canopy, those distributions have pre-built CartoPy packages available.
One option to work around this is to install MetPy 0.9:
pip install metpy==0.9
Do you use Conda? The easiest way to remedy this problem is to install CartoPy (or MetPy for that manner) via conda, so that all of the right dependencies are also downloaded: conda install -c conda-forge cartopy or conda install -c conda-forge metpy. Pip doesn't bring all of them together, so that leads to this problem being raised.
Thanks. Without conda, I was also able to complete this (more painful) installation:
- brew install geos
- brew install proj
- pip3 install cython
- pip3 install git+https://github.com/SciTools/cartopy.git#master 
(see http://louistiao.me/posts/installing-cartopy-on-mac-osx-1011/)

Uninstalled Pil/Pillow but can still import from it?

I've run the following commands on the virtual enviroment.
pip uninstall pillow
Skipping pillow as it is not installed.
pip uninstall pil
Skipping pil as it is not installed.
However when I do this in the console:
import PIL print PIL.PILLOW_VERSION
I get this: 5.3.0
import PIL print PIL.VERSION
I get this: 1.1.7
When I try to reinstall PIL in case there was an issue when installing it, I get this:
Could not find a version that satisfies the requirement pil (from versions: )
No matching distribution found for pil
When I try to uninstall from the python interpreter directly:
Cannot uninstall 'PIL'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
I'm trying to completely remove PIL and PILLOW on a windows machine.
I would recommend going into the Python interpreter and writing
>>> import PIL
>>> PIL
You should then see a path to the Pillow module, which you can manually remove.

from pysnmp.hlapi import * ImportError: No module named hlapi

I install the package and it dependencies module in ubuntu 15.10 but still it show error of
from pysnmp.hlapi import *
ImportError: No module named hlapi
I try to install it
sudo setup.py install
and
pip install pysnmp
But still its not working
Please help me to get it complete
apt-get install python-pip
pip install -U pysnmp
I find the solution
Remove all .egg file related to plugin then install with pip it work for me

pip install PIL doesn't install into virtualenv

How do I install PIL?
>pip install PIL
Downloading/unpacking PIL
Could not find any downloads that satisfy the requirement PIL
Some externally hosted files were ignored (use --allow-external PIL to allow).
Cleaning up...
No distributions at all found for PIL
Storing debug log for failure in /root/.pip/pip.log
>pip uninstall PIL
Can't uninstall 'PIL'. No files were found to uninstall.
pip install PIL --allow-external PIL --allow-unverified PIL
This is due to changes in the new version of Pip. Run pip --version and I'm willing to bet you are running 1.5. See the changelog here. This new default behavior enhances security. In PIL's case, the file you are installing actually comes from effbot.org (thus --allow-external) and PyPi doesn't have a checksum to guarantee validity (thus --allow-unverified).
Also, you might consider using the Pillow replacement to PIL.
Updated info for those reading in 2016:
--allow-external
and
--allow-unverified
were recently deprecated. Installing packages external to PyPi using pip is no longer supported: http://www.python.org/dev/peps/pep-0470/
As an alternative, when you really need to install that external package, you can download the source code and run its setup.py. For example, for PIL 1.1.7, download from http://www.pythonware.com/products/pil/, then:
$ tar xvfz Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
$ python setup.py install
(^ from the PIL README)
If you only want to install the package to a specific virtualenv, you can just activate your virtualenv first. ** thanks #Caumons
Alternatively, substitute the path to your virtualenv for 'python' in the third line, e.g.:
$ /home/username/virtualenv-name/bin/python setup.py install