Unable to import skeletonize in Python - python

I am trying to import skeletonize() function from skimage.morphology but it is throwing some unusual error.
This very command was working fine until my recent Windows update.
The respective versions that I am running are:
numpy 1.11.3
python 3.5.6
scikit-image 0.14.0
This is the command
from skimage.morphology import skeletonize
The error message that follows:
File "<ipython-input-69-3b41733bed63>", line 5, in <module>
from skimage.morphology import skeletonize
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\skimage\morphology\__init__.py", line 1, in <module>
from .binary import (binary_erosion, binary_dilation, binary_opening,
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\skimage\morphology\binary.py", line 6, in <module>
from .misc import default_selem
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\skimage\morphology\misc.py", line 5, in <module>
from .._shared.utils import warn
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\skimage\_shared\utils.py", line 10, in <module>
from ..util import img_as_float
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\skimage\util\__init__.py", line 6, in <module>
from .apply_parallel import apply_parallel
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\skimage\util\apply_parallel.py", line 8, in <module>
import dask.array as da
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\dask\array\__init__.py", line 5, in <module>
from .core import (Array, block, concatenate, stack, from_array, store,
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\dask\array\core.py", line 29, in <module>
from . import chunk
File "C:\Users\Nimesh Shahdadpuri\Anaconda3\lib\site-packages\dask\array\chunk.py", line 73, in <module>
nancumprod = npcompat.nancumprod
AttributeError: module 'dask.array.numpy_compat' has no attribute 'nancumprod'
Please help me resolve this error.

Related

ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found

I'm trying to install bern2 locally. bern2 installed successfully. when I started running, I got this error.
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/../../../libfaiss.so)
from normalizers.neural_normalizer import NeuralNormalizer
File "/home/ubuntu/BERN2/BERN2/normalizers/neural_normalizer.py", line 17, in <module>
import faiss
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/__init__.py", line 18, in <module>
from .loader import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/loader.py", line 65, in <module>
from .swigfaiss import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/swigfaiss.py", line 10, in <module>
from . import _swigfaiss
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/../../../libfaiss.so)
Traceback (most recent call last):
File "/home/ubuntu/BERN2/BERN2/server.py", line 1, in <module>
from app import create_app
File "/home/ubuntu/BERN2/BERN2/app/__init__.py", line 12, in <module>
import bern2
File "/home/ubuntu/BERN2/BERN2/bern2/__init__.py", line 1, in <module>
from bern2.bern2 import BERN2
File "/home/ubuntu/BERN2/BERN2/bern2/bern2.py", line 22, in <module>
from normalizer import Normalizer
File "/home/ubuntu/BERN2/BERN2/bern2/normalizer.py", line 11, in <module>
from normalizers.neural_normalizer import NeuralNormalizer
File "/home/ubuntu/BERN2/BERN2/normalizers/neural_normalizer.py", line 17, in <module>
import faiss
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/__init__.py", line 18, in <module>
from .loader import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/loader.py", line 65, in <module>
from .swigfaiss import *
File "/opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/swigfaiss.py", line 10, in <module>
from . import _swigfaiss
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/conda/envs/bern2/lib/python3.11/site-packages/faiss/../../../libfaiss.so)
The reason could be that the system path is not configured correctly. Try this,
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
Source:
https://www.tensorflow.org/install/pip

ImportError: cannot import name '_assert_shallow_structure' from 'tree'

I am getting that error while importing tensorflow_probability in IDLE(Default python editor). I don't get that error if use same code in VS code. Works perfectly fine in VS code.
Here are my imports
import numpy as np
import tensorflow.compat.v1 as tf
import tensorflow_probability as tfp
tf.disable_v2_behavior()
Here is complete error
Traceback (most recent call last):
File "C:\Python Scripts\pos_tagging.py", line 4, in <module>
import tensorflow_probability as tfp
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\__init__.py", line 77, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\__init__.py", line 21, in <module>
from tensorflow_probability.python import bijectors
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\bijectors\__init__.py", line 23, in <module>
from tensorflow_probability.python.bijectors.absolute_value import AbsoluteValue
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\bijectors\absolute_value.py", line 23, in <module>
from tensorflow_probability.python.bijectors import bijector
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\bijectors\bijector.py", line 31, in <module>
from tensorflow_probability.python.internal import distribution_util
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\internal\distribution_util.py", line 28, in <module>
from tensorflow_probability.python.internal import prefer_static
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\internal\prefer_static.py", line 30, in <module>
from tensorflow_probability.python.internal.backend import numpy as nptf
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\__init__.py", line 21, in <module>
from tensorflow_probability.python.internal.backend.numpy import bitwise
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\bitwise.py", line 23, in <module>
from tensorflow_probability.python.internal.backend.numpy import _utils as utils
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\_utils.py", line 26, in <module>
from tensorflow_probability.python.internal.backend.numpy import nest
File "C:\Users\aaaa\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\nest.py", line 34, in <module>
from tree import _assert_shallow_structure
ImportError: cannot import name '_assert_shallow_structure' from 'tree' (C:\Users\aaaa\AppData\Local\Programs\Python\Python38\Lib\idlelib\tree.py)
Python Version:3.8.5 64 bit
Windows machine
Look at where it's importing from (C:\Users\aaaa\AppData\Local\Programs\Python\Python38\Lib\idlelib\tree.py) I think you meant to import from dm-tree.
Here's my solution:
if you don't have dm-tree installed
pip install dm-tree
if you do, install PyCharm and use that to run the code. It wont have the conflict that IDLE would on the tree.py

What is this error when I run SHAP ? "cannot import name '_validate_lengths'"

When I run import shap I'm getting below error:
import shap
Traceback (most recent call last):
File "<ipython-input-1-efbb001a1501>", line 1, in <module>
import shap
File "C:\ProgramData\Anaconda3\lib\site-packages\shap\__init__.py", line 11, in <module>
from .plots.summary import summary_plot
File "C:\ProgramData\Anaconda3\lib\site-packages\shap\plots\summary.py", line 15, in <module>
from . import colors
File "C:\ProgramData\Anaconda3\lib\site-packages\shap\plots\colors.py", line 7, in <module>
import skimage.color
File "C:\ProgramData\Anaconda3\lib\site-packages\skimage\__init__.py", line 157, in <module>
from .util.dtype import *
File "C:\ProgramData\Anaconda3\lib\site-packages\skimage\util\__init__.py", line 8, in <module>
from .arraycrop import crop
File "C:\ProgramData\Anaconda3\lib\site-packages\skimage\util\arraycrop.py", line 8, in <module>
from numpy.lib.arraypad import _validate_lengths
ImportError: cannot import name '_validate_lengths'

Module not found when using scipy

I have recently properly installed numpy and scipy. The following line runs without error.
import scipy
I am experiencing difficulty using scipy.io.wavefile. I have been trying to use the code from the "best answer" of this post.
However, when I try the first line,
from scipy.io import wavfile
I receive the following error and traceback,
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from scipy.io import wavfile
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\__init__.py", line 97, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module>
from .mio import loadmat, savemat, whosmat
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\mio.py", line 12, in <module>
from .miobase import get_matfile_version, docfiller
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\miobase.py", line 22, in <module>
from scipy.misc import doccer
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\misc\__init__.py", line 68, in <module>
from scipy.interpolate._pade import pade as _pade
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\__init__.py", line 175, in <module>
from .interpolate import *
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\interpolate.py", line 21, in <module>
import scipy.special as spec
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs
ImportError: DLL load failed: The specified module could not be found.
I also receive an error and traceback if I try the following line instead,
import scipy.io.wavfile
receiving a different response,
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import scipy.io.wavfile
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\__init__.py", line 97, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module>
from .mio import loadmat, savemat, whosmat
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\mio.py", line 12, in <module>
from .miobase import get_matfile_version, docfiller
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\io\matlab\miobase.py", line 22, in <module>
from scipy.misc import doccer
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\misc\__init__.py", line 68, in <module>
from scipy.interpolate._pade import pade as _pade
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\__init__.py", line 175, in <module>
from .interpolate import *
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\interpolate\interpolate.py", line 21, in <module>
import scipy.special as spec
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\special\__init__.py", line 642, in <module>
from .basic import *
File "C:\Users\Me\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\special\basic.py", line 15, in <module>
from ._ufuncs import (ellipkm1, mathieu_a, mathieu_b, iv, jv, gamma,
ImportError: cannot import name 'ellipkm1' from 'scipy.special._ufuncs' (unknown location)
I do not understand why the module can not be found, if scipy is properly installed and can be imported by itself. I am using python 3.7.1. Could the code from the post be depreciated?
Apologies in advance for the long post.
Both error messages are complaining about the scipy.special._ufuncs module and a quick search revealed a few other posts, like this one, that suggest making sure you have the Visual C++ Redistributable Packages installed: https://www.microsoft.com/en-us/download/details.aspx?id=48145

NLTK Python error at running

I have installed the nltk in anaconda and tried some examples in this tutorial set pythonprogramming.net
After running the Classifier saving example it is showing some errors at the anaconda console as follows:
(C:\Users\Public\Anaconda) C:\Users\Kalanka PC>pickle.py
Traceback (most recent call last):
File "C:\Users\Kalanka PC\pickle.py", line 1, in <module>
import nltk
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\__init__.py", line 114, in <module>
from nltk.collocations import *
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\metrics\__init__.py", line 24, in <module>
from nltk.metrics.segmentation import windowdiff, ghd, pk
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\metrics\segmentation.py", line 45, in <module>
import numpy as np
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\core\__init__.py", line 36, in <module>
from . import numeric
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\core\numeric.py", line 37, in <module>
import pickle
File "C:\Users\Kalanka PC\pickle.py", line 4, in <module>
from nltk.corpus import movie_reviews
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\corpus\__init__.py", line 66, in <module>
from nltk.corpus.reader import *
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\corpus\reader\__init__.py", line 59, in <module>
from nltk.corpus.reader.tagged import *
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\corpus\reader\tagged.py", line 18, in <module>
from nltk.tag import str2tuple, map_tag
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\tag\__init__.py", line 63, in <module>
from nltk.tag.sequential import (SequentialBackoffTagger, ContextTagger,
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\tag\sequential.py", line 26, in <module>
from nltk.classify import NaiveBayesClassifier
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\classify\__init__.py", line 93, in <module>
from nltk.classify.scikitlearn import SklearnClassifier
File "C:\Users\Public\Anaconda\lib\site-packages\nltk\classify\scikitlearn.py", line 42, in <module>
from sklearn.feature_extraction import DictVectorizer
File "C:\Users\Public\Anaconda\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "C:\Users\Public\Anaconda\lib\site-packages\sklearn\base.py", line 10, in <module>
from scipy import sparse
File "C:\Users\Public\Anaconda\lib\site-packages\scipy\__init__.py", line 70, in <module>
from numpy.random import rand, randn
File "C:\Users\Public\Anaconda\lib\site-packages\numpy\random\__init__.py", line 99, in <module>
from .mtrand import *
File "numpy.pxd", line 86, in init mtrand (numpy\random\mtrand\mtrand.c:42488)
AttributeError: module 'numpy' has no attribute 'dtype'
when I try to install it again it shows as follows:
C:\Users\Kalanka PC>pip install nltk
Requirement already satisfied: nltk
in c:\users\public\anaconda\lib\site-packages Requirement already satisfied: six in c:\users\public\anaconda\lib\site-packages (from nltk)
Here the naming of the python file is same as the pickle.so it will confuse in loading the related files.
Ex:
the file name is pickle.py
and the code is as follows:
`import nltk`
`import random`
`import pickle`
You may be have saved the file with the name of pickle.py, as it tries to import your pickle file rather than the standard pickle in the module.
I had a similar problem while using pickle, I saved the code file with the name pickle. then when I execute it look for the file you created not the Standard module pickle

Categories