NLTK Not working in MAC OSX - scikit-learn

from nltk.tokenize import word_tokenize
k=[]
example=['Mary had a little lamb' , 'Jack went up the hill' , 'Jill followed suit' ,'i woke up suddenly','it was a really bad dream...']
for i in example:
k.append(word_tokenize(i))
I was trying to compile this code but its not compiling and is giving errors which goes as follows :
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import *
File "/Library/Python/2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "/Library/Python/2.7/site-packages/nltk/chunk/api.py", line 13, in <module>
from nltk.parse import ParserI
File "/Library/Python/2.7/site-packages/nltk/parse/__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser
File "/Library/Python/2.7/site-packages/nltk/parse/transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file
File "/Users/sudhir/Library/Python/2.7/lib/python/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Users/sudhir/Library/Python/2.7/lib/python/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/Users/sudhir/Library/Python/2.7/lib/python/site-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling

Related

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

I'm getting this error while running my python script on a Linux virtual machine.
Traceback (most recent call last): File "model.py",
line 7, in <module> from data_load import * File "/home/oshanjayawardanav100/biometrics-self-supervised/supervised_ucihar/data_load.py",
line 2, in <module> from sklearn.preprocessing import StandardScaler File "/opt/conda/lib/python3.7/site-packages/sklearn/__init__.py",
line 82, in <module> from .base import clone File "/opt/conda/lib/python3.7/site-packages/sklearn/base.py",
line 17, in <module> from .utils import _IS_32BIT File "/opt/conda/lib/python3.7/site-packages/sklearn/utils/__init__.py",
line 28, in <module> from .fixes import np_version, parse_version File "/opt/conda/lib/python3.7/site-packages/sklearn/utils/fixes.py",
line 20, in <module> import scipy.stats File "/opt/conda/lib/python3.7/site-packages/scipy/stats/__init__.py",
line 441, in <module> from .stats import * File "/opt/conda/lib/python3.7/site-packages/scipy/stats/stats.py",
line 43, in <module> from . import distributions File "/opt/conda/lib/python3.7/site-packages/scipy/stats/distributions.py",
line 8, in <module> from ._distn_infrastructure import (rv_discrete, rv_continuous, rv_frozen) File "/opt/conda/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py",
line 24, in <module> from scipy import optimize File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/__init__.py",
line 400, in <module> from .optimize import * File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/optimize.py",
line 36, in <module> from ._numdiff import approx_derivative File "/opt/conda/lib/python3.7/site-packages/scipy/optimize/_numdiff.py",
line 8, in <module> from ._group_columns import group_dense, group_sparse
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.26' not found (required by /opt/conda/lib/python3.7/site-packages/scipy/optimize/_group_columns.cpython-37m-x86_64-linux-gnu.so)`
I have no idea why I'm getting this.
I already tried this https://stackoverflow.com/a/55899959/15938633
But it is not working

ImportError: cannot import name 'NoReturn' PyTorch on MacOS Catalina

I'm having this weird problem in running torchvision in macOS Catalina. Here's the traceback
Traceback (most recent call last):
File "/Users/xdriyad/PycharmProjects/Resnet/main.py", line 1, in <module>
from model import ResNet50
File "/Users/xdriyad/PycharmProjects/Resnet/model.py", line 1, in <module>
import torch
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/__init__.py", line 573, in <module>
import torch.quantization
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/__init__.py", line 9, in <module>
from .quantize_fx import *
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/quantize_fx.py", line 1, in <module>
from .fx import Fuser # noqa: F401
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/fx/__init__.py", line 1, in <module>
from .quantize import Quantizer
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/quantization/fx/quantize.py", line 2, in <module>
from torch._fx import (
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/__init__.py", line 89, in <module>
from .symbolic_trace import symbolic_trace, Tracer
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/symbolic_trace.py", line 9, in <module>
from .proxy import Proxy, _create_proxy, TracerBase
File "/Users/xdriyad/PycharmProjects/Resnet/env/lib/python3.6/site-packages/torch/_fx/proxy.py", line 7, in <module>
from typing import Tuple, Dict, Optional, Iterable, NoReturn, Any, Union, Callable
ImportError: cannot import name 'NoReturn'

AttributeError: module 'tensorflow._api.v1.initializers' has no attribute 'TruncatedNormal'

I get the following error when I try to import sentence_transformers in python 3.6.7 and tensorflow==2.3.0. Can someone please help me with this? Seems like it's a bug in the transformers package.
import sentence_transformers
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/__init__.py", line 3, in <module>
from .datasets import SentencesDataset, SentenceLabelDataset, ParallelSentencesDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/__init__.py", line 1, in <module>
from .sampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/__init__.py", line 1, in <module>
from .LabelSampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/LabelSampler.py", line 6, in <module>
from ...datasets import SentenceLabelDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/SentenceLabelDataset.py", line 8, in <module>
from .. import SentenceTransformer
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/SentenceTransformer.py", line 11, in <module>
import transformers
File "/usr/local/lib/python3.6/site-packages/transformers/__init__.py", line 124, in <module>
from .pipelines import (
File "/usr/local/lib/python3.6/site-packages/transformers/pipelines.py", line 47, in <module>
from .modeling_tf_auto import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_auto.py", line 45, in <module>
from .modeling_tf_albert import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_albert.py", line 43, in <module>
from .modeling_tf_utils import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_utils.py", line 943, in <module>
def get_initializer(initializer_range: float = 0.02) -> tf.initializers.TruncatedNormal:
File "/usr/local/lib64/python3.6/site-packages/tensorflow/python/util/module_wrapper.py", line 194, in __getattr__
attr = getattr(self._tfmw_wrapped_module, name)
AttributeError: module 'tensorflow._api.v1.initializers' has no attribute 'TruncatedNormal'
Try:
initializer = tf.keras.initializers.TruncatedNormal()
or
initializer = tf.compat.v1.keras.initializers.TruncatedNormal()
In tensorflow2.3.0,you can't find 'TruncatedNormal' in module 'tensorflow._api.v1.initializers'.
Maybe this version has removed this attribute.

_iterative import Error in Python

I've been trying to run a code with python 3.4, but getting the error mentionned below. I tried all the other solutions suggested by the others in the other topics but nothing worked.
Thanks for the help
Traceback (most recent call last):
File "C:\Users\daly\Documents\Python\Machine Learning\regression.py", line
4, in <module>
from sklearn import preprocessing, cross_validation, svm, cluster
File "C:\Python34\lib\site-packages\sklearn\__init__.py", line 134, in
<module>
from .base import clone
File "C:\Python34\lib\site-packages\sklearn\base.py", line 12, in <module>
from .utils.fixes import signature
File "C:\Python34\lib\site-packages\sklearn\utils\__init__.py", line 11, in
<module>
from .validation import (as_float_array,
File "C:\Python34\lib\site-packages\sklearn\utils\validation.py", line 18, in
<module>
from ..utils.fixes import signature
File "C:\Python34\lib\site-packages\sklearn\utils\fixes.py", line 278, in
<module>
from scipy.sparse.linalg import lsqr as sparse_lsqr
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\__init__.py", line 114, in <module>
from .isolve import *
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Python34\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
from . import _iterative
ImportError: DLL load failed: Le module spécifié est introuvable.

After conda update --all, Qt breaks in iPython

I ran "conda update --all" and it updated a lot of things, including Python itself (from 3.5.2-0 to 3.5.3-1, I think) and PyQt. I have used Pip in the past; I imagine they might conflict. Now when I try to run an iPython session, as soon as I evaluate a plot, the kernel dies, and I get a lot of "ImportError: No module named 'PyQt4.QtGui'" errors.
I opened a Python shell and found that QtGui exists in PyQt5 but not PyQt4:
>>> import PyQt4
>>> import PyQt4.QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt4.QtGui'
>>> import PyQt5
>>> import PyQt5.QtGui
I run Linux, specifically Ubuntu 16.04.
What should I do?
Here's the full traceback:
Traceback (most recent call last):
File "/home/jeff/apps/pythoon-libs/lib/python3.5/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/home/jeff/apps/pythoon-libs/lib/python3.5/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/home/jeff/apps/pythoon-libs/lib/python3.5/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/ultratb.py", line 116, in <module>
from IPython.core import debugger
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/IPython/core/debugger.py", line 46, in <module>
from pdb import Pdb as OldPdb
File "/home/jeff/apps/pythoon-libs/lib/python3.5/pdb.py", line 75, in <module>
import code
File "/home/jeff/stats_with_luis/code.py", line 1, in <module>
import pandas
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/__init__.py", line 58, in <module>
from pandas.io.api import *
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/api.py", line 8, in <module>
from pandas.io.clipboard.clipboard import read_clipboard
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/clipboard/__init__.py", line 103, in <module>
copy, paste = determine_clipboard()
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/clipboard/__init__.py", line 76, in determine_clipboard
return init_qt_clipboard()
File "/home/jeff/apps/pythoon-libs/lib/python3.5/site-packages/pandas/io/clipboard/clipboards.py", line 49, in init_qt_clipboard
from PyQt4.QtGui import QApplication
ImportError: No module named 'PyQt4.QtGui'

Resources