pandas and numpy not functioning properly after installing SHAP - python-3.x

I'm new to python programming and want to install SHAP. After installing SHAP I'm getting error for basic codes, which were executing fine earlier(pandas and numpy).
My versions are
python 3.7.1
conda 4.7.11
pd__version__ :'0.23.4'
I have gone through similar problems and tried to troubleshoot but now neither SHAP, nor numpy,pandas are working properly.
I'm working in anaconda distribution for windows. And pip install --upgrade does not solve my problem.
#Explaining with SHAP
import shap
ImportError Traceback (most recent call last)
<ipython-input-15-f08ae71e45dd> in <module>
1 #Explaining with SHAP
----> 2 import shap
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\__init__.py in <module>
9 from .explainers.gradient import GradientExplainer
10 from .explainers.linear import LinearExplainer
---> 11 from .plots.summary import summary_plot
12 from .plots.dependence import dependence_plot
13 from .plots.force import force_plot, initjs, save_html
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\summary.py in <module>
13 pass
14 from . import labels
---> 15 from . import colors
16
17 # TODO: remove unused title argument / use title argument
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\colors.py in <module>
5
6 import numpy as np
----> 7 import skimage.color
8
9 try:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\__init__.py in <module>
174 dtype_limits)
175
--> 176 from .util.lookfor import lookfor
177 from .data import data_dir
178
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\__init__.py in <module>
6 from .apply_parallel import apply_parallel
7
----> 8 from .arraycrop import crop
9 from ._regular_grid import regular_grid, regular_seeds
10 from .unique import unique_rows
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\arraycrop.py in <module>
6
7 import numpy as np
----> 8 from numpy.lib.arraypad import _validate_lengths
9
10
ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib\arraypad.py)
Currently even pd.read_csv is not working
os.chdir(r"C:\Users\z026355\Desktop\Titanic")
with open("train.csv", encoding="utf8", errors='ignore') as g:
data = pd.read_csv(g)
Traceback (most recent call last):
File "<ipython-input-136-f58724e2278b>", line 2, in <module>
data = pd.read_csv(g)
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 678, in parser_f
error_bad_lines=error_bad_lines,
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 440, in _read
filepath_or_buffer, encoding, compression
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 774, in __init__
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 797, in _get_options_with_defaults
Passed dialect overrides any of the related parser options
AttributeError: module 'pandas.compat' has no attribute 'iteritems'
Upgrading or re installing pandas gives requirement already fulfilled.

Related

No module named keras.api Mask R CNN

I am in the demo file of the Mask R CNN repo from matterport. Trying to run the first cell but encountering the following error. I have keras 2.3.0 installed. Running Python 3.8. The below is a trace of the error from the model.py file inside the Mask R CNN repo, which came with the clone. Thanks!
The repo referred to is here: https://github.com/matterport/Mask_RCNN.git
Thank you all for your kind support.
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_3220/983756133.py in <module>
7 import matplotlib
8 import matplotlib.pyplot as plt
----> 9 import keras
10
11 # Root directory of the project
~\OneDrive\New Project\myenv1\lib\site-packages\keras\__init__.py in <module>
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
~\OneDrive\New Project\myenv1\lib\site-packages\keras\utils\__init__.py in <module>
24 from .layer_utils import get_source_inputs
25 from .layer_utils import print_summary
---> 26 from .vis_utils import model_to_dot
27 from .vis_utils import plot_model
28 from .np_utils import to_categorical
~\OneDrive\New Project\myenv1\lib\site-packages\keras\utils\vis_utils.py in <module>
5
6 import os
----> 7 from ..models import Model
8 from ..layers.wrappers import Wrapper
9
~\OneDrive\New Project\myenv1\lib\site-packages\keras\models.py in <module>
10 from .engine.input_layer import Input
11 from .engine.input_layer import InputLayer
---> 12 from .engine.training import Model
13 from .engine.sequential import Sequential
14 from .engine.saving import save_model
~\OneDrive\New Project\myenv1\lib\site-packages\keras\engine\__init__.py in <module>
6 from .base_layer import Layer
7 from .network import get_source_inputs
----> 8 from .training import Model
~\OneDrive\New Project\myenv1\lib\site-packages\keras\engine\training.py in <module>
12 from .network import Network
13 from .base_layer import Layer
---> 14 from . import training_utils
15 from . import training_arrays
16 from . import training_generator
~\OneDrive\New Project\myenv1\lib\site-packages\keras\engine\training_utils.py in <module>
15 from .. import backend as K
16 from .. import losses
---> 17 from .. import metrics as metrics_module
18 from ..utils import Sequence
19 from ..utils import generic_utils
~\OneDrive\New Project\myenv1\lib\site-packages\keras\metrics.py in <module>
1848 import tensorflow as tf
1849 if tf.__version__ >= '2.0.0':
-> 1850 BaseMeanIoU = tf.keras.metrics.MeanIoU
1851
1852
~\OneDrive\New Project\myenv1\lib\site-packages\tensorflow\python\util\lazy_loader.py in __getattr__(self, item)
60
61 def __getattr__(self, item):
---> 62 module = self._load()
63 return getattr(module, item)
64
~\OneDrive\New Project\myenv1\lib\site-packages\tensorflow\python\util\lazy_loader.py in _load(self)
43 """Load the module and insert it into the parent's globals."""
44 # Import the target module and insert it into the parent's namespace
---> 45 module = importlib.import_module(self.__name__)
46 self._parent_module_globals[self._local_name] = module
47
~\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
ModuleNotFoundError: No module named 'keras.api'
I read the repo that you have referred. You maybe try run your code with environment below:
Python 3.4, TensorFlow 1.3, Keras 2.0.8

ImportError when importing brightway2

I am getting this import error when trying to import brightway:
import brightway2 as bw
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a3ddbb8a34e8> in <module>
----> 1 import brightway2 as bw
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/brightway2/__init__.py in <module>
1 # -*- coding: utf-8 -*
----> 2 from bw2data import *
3 from bw2calc import *
4 from bw2io import *
5
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/bw2data/__init__.py in <module>
31
32 from .configuration import config
---> 33 from .project import projects
34 from .utils import set_data_dir
35 from .meta import (
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/bw2data/project.py in <module>
6 from .errors import ReadOnlyProject
7 from .filesystem import safe_filename, create_dir
----> 8 from .sqlite import PickleField, create_database
9 from .utils import python_2_unicode_compatible
10 from fasteners import InterProcessLock
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/bw2data/sqlite.py in <module>
4
5 from peewee import SqliteDatabase, BlobField, Model, TextField
----> 6 from playhouse.shortcuts import RetryOperationalError
7 import os
8 try:
ImportError: cannot import name 'RetryOperationalError'
I am using macOS system. I have tried reinstalling conda as well but I keep getting the same error, so I am not sure what is wrong. Any help or suggestions would be greatly appreciated!
Your version of bw2data is very out of date. Since 2018, i.e. version 3.3, this code has changed. Upgrade bw2data using either conda or pip, depending on how you installed it in the first place.

Trouble importing modules into ipython

On a freshly installed Windows 10 machine, I installed the newest 64bit version of anaconda. Now when I try importing modules into ipython, I get errors. Some sample errors are reproduced below.
I am new to Python and Programming, so would appreciate a bit of help. This is a brand new Lenovo laptop, so there's no scope for any Python version conflict etc. (since nothing was installed on it earlier).
In [1]: import sklearn
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn
C:\Software\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
74 else:
75 from . import __check_build
---> 76 from .base import clone
77 from .utils._show_versions import show_versions
78
C:\Software\anaconda3\lib\site-packages\sklearn\base.py in <module>
11 import re
12
---> 13 import numpy as np
14
15 from . import __version__
C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
32
33 with RTLD_for_MKL():
---> 34 from . import _mklinit
35
36 del RTLD_for_MKL
ImportError: DLL load failed: The specified module could not be found.
In [2]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt
C:\Software\anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
136 # cbook must import matplotlib only within function
137 # definitions, so it is safe to import from it here.
--> 138 from . import cbook, rcsetup
139 from matplotlib.cbook import (
140 MatplotlibDeprecationWarning, dedent, get_label, sanitize_sequence)
C:\Software\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in <module>
29 from weakref import WeakMethod
30
---> 31 import numpy as np
32
33 import matplotlib
C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
32
33 with RTLD_for_MKL():
---> 34 from . import _mklinit
35
36 del RTLD_for_MKL
ImportError: DLL load failed: The specified module could not be found.
In [3]: import pystan
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-ca8618bb8e4a> in <module>
----> 1 import pystan
ModuleNotFoundError: No module named 'pystan'
In [4]:
After a lot of google searching, I found a few sites that touch upon some closely related issues (ex. https://github.com/stan-dev/pystan/issues/520). It so happens that one needs to add some anaconda directroties to the Windows path. I added anaconda/Library/bin, anaconda/Scripts to the path. Now everything is working as expected.

How to Fix: "ImportError: DLL load failed The specified procedure could not be found." when the DLLs are there

Updated to new Anaconda 2018, opened a jupyter notebook that worked prior to the update. Having problems with loading seaborn into the script. Tried following several threads on this but nothing worked question.
I've tried:
-Setting Enviromental Variables
-Reinstalling Anaconda2018
-Uninstalled and reinstalled seaborn using conda
-Reinstalled SciPy
Running out of options as I want to use Seaborn 0.9.0 and python-3.7 but I cannot seem to get 3.7 to play with 0.9.0. Help?
import seaborn as sns
ImportError Traceback (most recent call last)
<ipython-input-1-a84c0541e888> in <module>
----> 1 import seaborn as sns
~\Anaconda3\lib\site-packages\seaborn\__init__.py in <module>
4
5 # Import seaborn objects
----> 6 from .rcmod import *
7 from .utils import *
8 from .palettes import *
~\Anaconda3\lib\site-packages\seaborn\rcmod.py in <module>
3 import functools
4 import matplotlib as mpl
----> 5 from . import palettes, _orig_rc_params
6
7
~\Anaconda3\lib\site-packages\seaborn\palettes.py in <module>
10 from .external.six.moves import range
11
---> 12 from .utils import desaturate, set_hls_values, get_color_cycle
13 from .colors import xkcd_rgb, crayons
14
~\Anaconda3\lib\site-packages\seaborn\utils.py in <module>
5
6 import numpy as np
----> 7 from scipy import stats
8 import pandas as pd
9 import matplotlib as mpl
~\Anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
343 from __future__ import division, print_function, absolute_import
344
--> 345 from .stats import *
346 from .distributions import *
347 from .morestats import *
~\Anaconda3\lib\site-packages\scipy\stats\stats.py in <module>
169 import scipy.special as special
170 import scipy.linalg as linalg
--> 171 from . import distributions
172 from . import mstats_basic
173 from ._distn_infrastructure import _lazywhere
~\Anaconda3\lib\site-packages\scipy\stats\distributions.py in <module>
8 from __future__ import division, print_function, absolute_import
9
---> 10 from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
11 rv_frozen)
12
~\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py in <module>
22
23 # for root finding for discrete distribution ppf, and max likelihood estimation
---> 24 from scipy import optimize
25
26 # for functions of continuous distributions (e.g. moments, entropy, cdf)
~\Anaconda3\lib\site-packages\scipy\optimize\__init__.py in <module>
269
270 from .optimize import *
--> 271 from ._minimize import *
272 from ._root import *
273 from .minpack import *
~\Anaconda3\lib\site-packages\scipy\optimize\_minimize.py in <module>
19 from scipy._lib.six import callable
20
---> 21 from scipy.sparse.linalg import LinearOperator
22
23 # unconstrained minimization
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
115 from .dsolve import *
116 from .interface import *
--> 117 from .eigen import *
118 from .matfuncs import *
119 from ._onenormest import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
9 from __future__ import division, print_function, absolute_import
10
---> 11 from .arpack import *
12 from .lobpcg import *
13
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
20 from __future__ import division, print_function, absolute_import
21
---> 22 from .arpack import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py in <module>
43 __all__ = ['eigs', 'eigsh', 'svds', 'ArpackError', 'ArpackNoConvergence']
44
---> 45 from . import _arpack
46 import numpy as np
47 import warnings
ImportError: DLL load failed: The specified procedure could not be found.
Any Tips on how to make my question better would also be welcomed as I want to get better at asking these questions.
I have met the same problem and be puzzled by it either this morning........
By carefully checking the Traceback
----> 4 from scipy.sparse.linalg import LinearOperator
It's the issue of scipy, not seaborn.
I try to uninstall conda versions and install pip versions scipy and numpy, it works now. please have a try, hopefully it could help u too.
$> conda remove --force numpy, scipy
$> pip install numpy
$> pip install scipy
i have removed completely seaborn, numpy and scipy then i reinstalled them and it works for me.
In my anaconda Powershell i excuted this command:
conda remove --force seaborn numpy scipy
then, in jupyter notebook and execut this in one cell.
pip install seaborn numpy scipy

How do you run tensorflow on colaboratory?

I'm trying to use Google's Colaboratory. The first line of output was hopeful.
Using TensorFlow backend.
But then I got this error message.
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
That error apparently triggered another error. (Sorry for the long stack trace, but the error message itself suggested including it when asking for help.)
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-6-0b846698ae4a> in <module>()
2 import numpy as np
3 import matplotlib.pylab as plt
----> 4 from keras.models import Sequential
5 from keras.layers import Dense, InputLayer
6
/usr/local/lib/python3.6/dist-packages/keras/__init__.py in <module>()
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
/usr/local/lib/python3.6/dist-packages/keras/utils/__init__.py in <module>()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
/usr/local/lib/python3.6/dist-packages/keras/utils/conv_utils.py in <module>()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
/usr/local/lib/python3.6/dist-packages/keras/backend/__init__.py in <module>()
82 elif _BACKEND == 'tensorflow':
83 sys.stderr.write('Using TensorFlow backend.\n')
---> 84 from .tensorflow_backend import *
85 else:
86 raise ValueError('Unknown backend: ' + str(_BACKEND))
/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in <module>()
3 from __future__ import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.training import moving_averages
7 from tensorflow.python.ops import tensor_array_ops
/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25 # pylint: disable=wildcard-import
26 from tensorflow.tools.api.generator.api import * # pylint: disable=redefined-builtin
/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Below that was a suggestion to consult https://www.tensorflow.org/install/install_sources#common_installation_problems.
But that page is about installing TensorFlow from source. I'm not trying to install from source. I just want a runnable version that I can call.
Any suggestions would be appreciated.
Thanks.

Resources