ImportError: [...] Library not loaded [...] Reason: Incompatible library version - python-imaging-library

I just downloaded scikit-image and I got an error message by simply trying to import the packages to run a tutorial example of the scikit website ("Gabor filter banks for texture classification"). See error message below.
I re-installed libtiff (using pip and homebrew) and Pillow (using conda), following the advice of some scikit-image developers. But the problem persists. I have the latest version of pillow installed (4.2.1), and I made sure to uninstall PIL before, and to build pillow from source to install all the dependencies.
ImportError Traceback (most recent call last)
<ipython-input-1-6205bd0cfb9d> in <module>()
5 from scipy import ndimage as ndi
6
----> 7 from skimage import data
8 from skimage.util import img_as_float
9 from skimage.filters import gabor_kernel
/Applications/anaconda/lib/python2.7/site-packages/skimage/data/__init__.py in <module>()
14
15 from .. import data_dir
---> 16 from ..io import imread, use_plugin
17 from .._shared._warnings import expected_warnings
18 from ._binary_blobs import binary_blobs
/Applications/anaconda/lib/python2.7/site-packages/skimage/io/__init__.py in <module>()
5 """
6
----> 7 from .manage_plugins import *
8 from .sift import *
9 from .collection import *
/Applications/anaconda/lib/python2.7/site-packages/skimage/io/manage_plugins.py in <module>()
26 from glob import glob
27
---> 28 from .collection import imread_collection_wrapper
29
30
/Applications/anaconda/lib/python2.7/site-packages/skimage/io/collection.py in <module>()
10 import numpy as np
11 import six
---> 12 from PIL import Image
13
14 from ..external.tifffile import TiffFile
/Applications/anaconda/lib/python2.7/site-packages/PIL/Image.py in <module>()
54 # Also note that Image.core is not a publicly documented interface,
55 # and should be considered private and subject to change.
---> 56 from . import _imaging as core
57 if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
58 raise ImportError("The _imaging extension was built for another "
ImportError: dlopen(/Applications/anaconda/lib/python2.7/site-
packages/PIL/_imaging.so, 2): Library not loaded: #rpath/libtiff.5.dylib
Referenced from: /Applications/anaconda/lib/python2.7/site-
packages/PIL/_imaging.so
Reason: Incompatible library version: _imaging.so requires version 8.0.0 or
later, but libtiff.5.dylib provides version 7.0.0

Related

Seaborn will not import in Jupyter notebook

I just used used the Seaborn library about 5 days ago, no problems.
Tried to use it yesterday and it's giving an error when I try to import. Someone about a year ago had the same exact problem but their fix did not work for me. I'm trying to complete a project and this is a huge set back so if anyone can help, please do!
input
import seaborn as sns
result
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-a84c0541e888> in <module>
----> 1 import seaborn as sns
/opt/anaconda3/envs/datascience/lib/python3.6/site-packages/seaborn/__init__.py in <module>
8 from .palettes import *
9 from .linearmodels import *
---> 10 from .categorical import *
11 from .distributions import *
12 from .timeseries import *
/opt/anaconda3/envs/datascience/lib/python3.6/site-packages/seaborn/categorical.py in <module>
5 from scipy import stats
6 import pandas as pd
----> 7 from pandas.core.series import remove_na
8 import matplotlib as mpl
9 from matplotlib.collections import PatchCollection
ImportError: cannot import name 'remove_na'

Python import pdfplumber error " ModuleNotFoundError: No module named 'chardet' "

I encountered an error while importing pdfplumber in Python3, indicating module chardet is missing. However, running pip list from the cmd confirms that the package is installed, version 3.0.4. Anyone had similar experience? Any resolution?
Error Message:
~\AppData\Roaming\Python\Python37\site-packages\pdfminer\utils.py in <module>
3 """
4 import struct
----> 5 import chardet # For str encoding detection
6
7 # from sys import maxint as INF doesn't work anymore under Python3, but PDF
ModuleNotFoundError: No module named 'chardet'
Error: No module named chardet

AttributeError: module 'pytest' has no attribute 'mark' for "from sklearn.model_selection import cross_val_score"

When i try to import "sklearn" and use it, i am getting "Attribute Error",
## Modeling
# Multiple Linear REgression (Least Square fitting)
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LinearRegression
The error from Jupyter notebook is as below,
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-33-9fc361c79a41> in <module>()
2 # Multiple Linear REgression (Least Square fitting)
3
----> 4 from sklearn.model_selection import cross_val_score
5 from sklearn.linear_model import LinearRegression
6 #from sklearn.model_selection.train_test_split import train_test_split
D:\Anaconda_details\lib\site-packages\sklearn\model_selection\__init__.py in <module>()
17 from ._split import check_cv
18
---> 19 from ._validation import cross_val_score
20 from ._validation import cross_val_predict
21 from ._validation import cross_validate
D:\Anaconda_details\lib\site-packages\sklearn\model_selection\_validation.py in <module>()
29 from ..utils._joblib import logger
30 from ..externals.six.moves import zip
---> 31 from ..metrics.scorer import check_scoring, _check_multimetric_scoring
32 from ..exceptions import FitFailedWarning
33 from ._split import check_cv
D:\Anaconda_details\lib\site-packages\sklearn\metrics\__init__.py in <module>()
5
6
----> 7 from .ranking import auc
8 from .ranking import average_precision_score
9 from .ranking import coverage_error
D:\Anaconda_details\lib\site-packages\sklearn\metrics\ranking.py in <module>()
34 from ..utils.sparsefuncs import count_nonzero
35 from ..exceptions import UndefinedMetricWarning
---> 36 from ..preprocessing import label_binarize
37
38 from .base import _average_binary_score
D:\Anaconda_details\lib\site-packages\sklearn\preprocessing\__init__.py in <module>()
4 """
5
----> 6 from ._function_transformer import FunctionTransformer
7
8 from .data import Binarizer
D:\Anaconda_details\lib\site-packages\sklearn\preprocessing\_function_transformer.py in <module>()
3 from ..base import BaseEstimator, TransformerMixin
4 from ..utils import check_array
----> 5 from ..utils.testing import assert_allclose_dense_sparse
6 from ..externals.six import string_types
7
D:\Anaconda_details\lib\site-packages\sklearn\utils\testing.py in <module>()
758 import pytest
759
--> 760 skip_if_32bit = pytest.mark.skipif(_IS_32BIT,
761 reason='skipped on 32bit platforms')
762 skip_travis = pytest.mark.skipif(os.environ.get('TRAVIS') == 'true',
AttributeError: module 'pytest' has no attribute 'mark'
I have tried install/uninstall using pip
pip uninstall scikit-learn
pip install scikit-learn
(base) C:\Users\shashi>pip install scikit-learn
I am not able to uninstall sckit-learn package, it seems to be some path issue,
(base) C:\Users\shashi>pip uninstall scikit-learn
Uninstalling scikit-learn-0.20.0:
Would remove:
d:\anaconda_details\lib\site-packages\scikit_learn-0.20.0-py3.5.egg-info
d:\anaconda_details\lib\site-packages\sklearn
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
File "D:\Anaconda_details\lib\shutil.py", line 544, in move
os.rename(src, real_dst)
OSError: [WinError 17] The system cannot move the file to a different disk drive: 'd:\\anaconda_details\\lib\\site-packages\\sklearn' -> 'C:\\Users\\sh289528\\AppData\\Local\\Temp\\pip-uninstall-w3d2aqtz\\anaconda_details\\lib\\site-packages\\sklearn'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Anaconda_details\lib\site-packages\pip\_internal\basecommand.py", line 228, in main
status = self.run(options, args)
File "D:\Anaconda_details\lib\site-packages\pip\_internal\commands\uninstall.py", line 68, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "D:\Anaconda_details\lib\site-packages\pip\_internal\req\req_install.py", line 661, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "D:\Anaconda_details\lib\site-packages\pip\_internal\req\req_uninstall.py", line 219, in remove
renames(path, new_path)
File "D:\Anaconda_details\lib\site-packages\pip\_internal\utils\misc.py", line 273, in renames
shutil.move(old, new)
File "D:\Anaconda_details\lib\shutil.py", line 556, in move
rmtree(src)
File "D:\Anaconda_details\lib\shutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "D:\Anaconda_details\lib\shutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "D:\Anaconda_details\lib\shutil.py", line 389, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "D:\Anaconda_details\lib\shutil.py", line 387, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'd:\\anaconda_details\\lib\\site-packages\\sklearn\\feature_extraction\\_hashing.cp35-win_amd64.pyd'
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I am getting error again when i try to pip install.
(base) C:\Users\shashi>pip install scikit-learn
Collecting scikit-learn
Downloading https://files.pythonhosted.org/packages/d3/fa/b50821115c16e9b8ca307d3788e3dd1ec71cade3e564953ed7330a1fa3e0/scikit_learn-0.20.3-cp35-cp35m-win_amd64.whl (4.8MB)
100% |################################| 4.8MB 546kB/s
Requirement already satisfied: scipy>=0.13.3 in d:\anaconda_details\lib\site-packages (from scikit-learn) (1.1.0)
Requirement already satisfied: numpy>=1.8.2 in d:\anaconda_details\lib\site-packages (from scikit-learn) (1.15.2)
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
Installing collected packages: scikit-learn
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'D:\\Anaconda_details\\Lib\\site-packages\\sklearn\\feature_extraction\\_hashing.cp35-win_amd64.pyd'
Consider using the `--user` option or check the permissions.
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I have tried with conda uninstall and install. but that didn't help me either.
(base) C:\Users\shashi>conda update scikit-learn
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.5.5
latest version: 4.6.9
Please update conda by running
$ conda update -n base -c defaults conda

Fail to import IPython parallel in Jupyter

I recently made an update of IPython to 4.0.0 and installed Jupyter 4.0.6.
I wanted to use Ipython parallel, and after starting the engines in the notebook, I imported:
from IPython import parallel
And it fails:
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
warn("IPython.utils.traitlets has moved to a top-level traitlets package.")
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/pickleutil.py:3: UserWarning: IPython.utils.pickleutil has moved to ipykernel.pickleutil
warn("IPython.utils.pickleutil has moved to ipykernel.pickleutil")
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/utils/jsonutil.py:3: UserWarning: IPython.utils.jsonutil has moved to jupyter_client.jsonutil
warn("IPython.utils.jsonutil has moved to jupyter_client.jsonutil")
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-5652e9e33a4d> in <module>()
----> 1 from IPython import parallel
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/parallel/__init__.py in <module>()
31
32 from .client.asyncresult import *
---> 33 from .client.client import Client
34 from .client.remotefunction import *
35 from .client.view import *
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/parallel/client/client.py in <module>()
38 from IPython.utils.capture import RichOutput
39 from IPython.utils.coloransi import TermColors
---> 40 from IPython.utils.jsonutil import rekey, extract_dates, parse_date
41 from IPython.utils.localinterfaces import localhost, is_local_ip
42 from IPython.utils.path import get_ipython_dir
ImportError: cannot import name rekey
So I tried:
pip install rekey
But no distribution were found.
Note that it fails the same way in the notebook, be it open with ipython notebook or jupyter notebook, and in the console.
Also note that there is a warning:
UserWarning: IPython.utils.jsonutil has moved to jupyter_client.jsonutil
But rekey does not exist in the module jupyter_client.jsonutil
Question: How can I have IPython parallel to work within Jupyter ?
What am I missing ?
I found the problem I think (at least it works):
First, I had to import ipyparallel instead of IPython.parallel
See here: http://jupyter.readthedocs.org/en/latest/migrating.html#imports
EDIT: I get this OSError, but the fix was apparently useless, and it works without. I still don't get why I had this error, though.
Then, I had another error, when starting the client:
OSError: Connection file '~/.ipython/profile_default/security/ipcontroller-client.json' not found.
You have attempted to connect to an IPython Cluster but no Controller could be found.
Please double-check your configuration and ensure that a cluster is running.
So I just copy the directory ~/.ipython/profile_default to ~/.jupyter/profile_default
And it works!

from pylab import * fails on RHEL 6 due to need for GLIBC 2.14

How might I get a pylab import that works... I'm willing to recompile for my box, but need to know where to put everything this works for all the users. Note that GLIB2.14 is required by libpng16.so.16, which was the original "trip-up" point. But, I found a version of that, and am now stuck here. Here's the error:
In [2]:
from pylab import *
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-de1a8241b951> in <module>()
----> 1 from pylab import *
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pylab.py in <module>()
----> 1 from matplotlib.pylab import *
2 import matplotlib.pylab
3 __doc__ = matplotlib.pylab.__doc__
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/pylab.py in <module>()
224 # make mpl.finance module available for backwards compatability, in case folks
225 # using pylab interface depended on not having to import it
--> 226 import matplotlib.finance
227
228 from matplotlib.dates import date2num, num2date,\
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/finance.py in <module>()
21 from matplotlib.dates import date2num
22 from matplotlib.cbook import iterable, mkdirs
---> 23 from matplotlib.collections import LineCollection, PolyCollection
24 from matplotlib.colors import colorConverter
25 from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
21 import matplotlib.artist as artist
22 from matplotlib.artist import allow_rasterization
---> 23 import matplotlib.backend_bases as backend_bases
24 import matplotlib.path as mpath
25 from matplotlib import _path
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
48
49 import matplotlib.tight_bbox as tight_bbox
---> 50 import matplotlib.textpath as textpath
51 from matplotlib.path import Path
52 from matplotlib.cbook import mplDeprecation
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
9 from matplotlib.path import Path
10 from matplotlib import rcParams
---> 11 import matplotlib.font_manager as font_manager
12 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
13 from matplotlib.ft2font import LOAD_TARGET_LIGHT
/users/p/c/pclemins/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/font_manager.py in <module>()
51 import matplotlib
52 from matplotlib import afm
---> 53 from matplotlib import ft2font
54 from matplotlib import rcParams, get_cachedir
55 from matplotlib.cbook import is_string_like
ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/libpng16.so.16)
Apparently, you installed a wrong version of libpng16, perhaps from an rpm or compiled for a different system, not the OS you are using.
The canopy package manager has the correct version of libpng available, if you install that things should work fine. You can install it from the canopy package manager gui or via the enpkg libpng command. (Unfortunately it appears libpng is missing from default canopy install whereas it should have been included.)