I was using sklearn library for many days, but sudunly today I cant import sklearn. There is some problem in sicpy library which I can't find solution for.
And this problem started exatly after I ran apt-get update
Here is the error I am getting.
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/usr/local/lib/python2.7/dist-packages/sklearn/base.py", line 12, in <module>
from .utils.fixes import signature
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/validation.py", line 18, in <module>
from ..utils.fixes import signature
File "/usr/local/lib/python2.7/dist-packages/sklearn/utils/fixes.py", line 45, in <module>
from scipy.special import expit # SciPy >= 0.10
File "/usr/lib/python2.7/dist-packages/scipy/special/__init__.py", line 643, in <module>
from ._ellip_harm import ellip_harm, ellip_harm_2, ellip_normal
File "/usr/lib/python2.7/dist-packages/scipy/special/_ellip_harm.py", line 7, in <module>
from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm
File "scipy/special/_ellip_harm_2.pyx", line 5, in init scipy.special._ellip_harm_2 (scipy/special/_ellip_harm_2.c:7330)
File "/usr/lib/python2.7/dist-packages/scipy/integrate/__init__.py", line 59, in <module>
from ._bvp import solve_bvp
File "/usr/lib/python2.7/dist-packages/scipy/integrate/_bvp.py", line 10, in <module>
from scipy.sparse.linalg import splu
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/__init__.py", line 112, in <module>
from .isolve import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/__init__.py", line 6, in <module>
from .iterative import *
File "/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/iterative.py", line 84, in <module>
def bicg(A, b, x0=None, tol=1e-5, maxiter=None, xtype=None, M=None, callback=None):
File "/usr/lib/python2.7/dist-packages/scipy/_lib/_threadsafety.py", line 59, in decorator
return lock.decorate(func)
File "/usr/lib/python2.7/dist-packages/scipy/_lib/_threadsafety.py", line 47, in decorate
return scipy._lib.decorator.decorate(func, caller)
AttributeError: 'module' object has no attribute 'decorate'
>>>
Solutions I tried:
Restarting pc
Reinstalling sklearn
Reinstalling sicpy
Banging my head to pc
Please help soon, as I need it to complete my semester project.
Update python-decorator.
Looks like dependency bug.
Related
$ python vmuc.py compress /home2/kubra/JPEG/Stanford_Area_2.ply ../models/Geometry-only/Codec/0.00025/checkpoint_best_loss.pth.tar ../results/G0.00025
Traceback (most recent call last):
File "/home2/kubra/JPEG/JPEG_PCC_VM/jpeg-pleno-pc-vm-main/src/vmuc.py", line 13, in <module>
import loss_functions
File "/home2/kubra/JPEG/JPEG_PCC_VM/jpeg-pleno-pc-vm-main/src/loss_functions.py", line 3, in <module>
from sklearn.neighbors import NearestNeighbors
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/sklearn/__init__.py", line 82, in <module>
from .base import clone
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/sklearn/base.py", line 17, in <module>
from .utils import _IS_32BIT
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/sklearn/utils/__init__.py", line 29, in <module>
from .fixes import parse_version, threadpool_info
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/sklearn/utils/fixes.py", line 19, in <module>
import scipy.stats
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/scipy/stats/__init__.py", line 467, in <module>
from ._stats_py import *
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/scipy/stats/_stats_py.py", line 39, in <module>
from scipy.spatial.distance import cdist
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/scipy/spatial/__init__.py", line 105, in <module>
from ._kdtree import *
File "/home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/scipy/spatial/_kdtree.py", line 5, in <module>
from ._ckdtree import cKDTree, cKDTreeNode
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/scipy/spatial/_ckdtree.cpython-39-x86_64-linux-gnu.so)``
I'm currently working on point clouds codec. I tried encoding a point cloud but I keep getting the same error:
"/lib/x86_64-linux-gnu/libstdc++.so.6: version \`GLIBCXX_3.4.29' not found (required by /home/kubra/anaconda3/envs/myenv/lib/python3.9/site-packages/scipy/spatial/\_ckdtree.cpython-39-x86_64-linux-gnu.so)"
It says, apparently the version of GLIBCXX is not found whatsoever.. I tried updating my libstdc, creating new env with updated packages etc but it didnt workk for me. I have no idea of why it doesn't work and what I need to do. Could anyone please tell me what should I do?
I am using pyrogram in a program but when i run the program it gives import error
i uninstalled and reinstalled it but the problem is still there.
I am not able to fix it i have tried the previous version as well as the new version but the problem is the same.
Here is the output:
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrogram
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/__init__.py", line 40, in <module>
from . import raw, types, filters, handlers, emoji
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/types/__init__.py", line 22, in <module>
from .input_media import *
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/types/input_media/__init__.py", line 25, in <module>
from .input_phone_contact import InputPhoneContact
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/types/input_media/input_phone_contact.py", line 20, in <module>
from pyrogram.session.internals import MsgId
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/session/__init__.py", line 19, in <module>
from .auth import Auth
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/session/auth.py", line 29, in <module>
from pyrogram.crypto import aes, rsa, prime
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/crypto/prime.py", line 19, in <module>
from random import randint
File "/home/ak/Desktop/development/bots/pyrogramplugins/multiuserbot/final/random.py", line 1, in <module>
from pyrogram import Client, filters, idle
File "/home/ak/.local/lib/python3.9/site-packages/pyrogram/filters.py", line 24, in <module>
from pyrogram.types import Message, CallbackQuery, InlineQuery, InlineKeyboardMarkup, ReplyKeyboardMarkup, Update
ImportError: cannot import name 'Message' from partially initialized module 'pyrogram.types' (most likely due to a circular import) (/home/ak/.local/lib/python3.9/site-packages/pyrogram/types/__init__.py)
>>>
I am stuck here i have tried everything i know but not able to fix it
It is because the file name is same as the module name which I am using in code.
Change the file name and never give file a name which is the name of a module
I am currently running Anaconda 1.9.2 on Ubuntu 18.04. I updated to the Anaconda 1.9.2 version and since then I am facing problems to import tensorflow, pandas, sklearn etc. I get the following error message when I'm trying to import.
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
**>>> import tensorflow**
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/google/protobuf/descriptor.py", line 40, in <module>
from google.protobuf.internal import api_implementation
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/google/protobuf/internal/api_implementation.py", line 154, in <module>
from google.protobuf.pyext import _message
SystemError: initialization of _message raised unreported exception
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/__init__.py", line 42, in <module>
from pandas.core.api import *
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/core/api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/core/groupby/__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/core/groupby/groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/core/frame.py", line 66, in <module>
from pandas.core.generic import NDFrame, _shared_docs
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/core/generic.py", line 102, in <module>
class NDFrame(PandasObject, SelectionMixin):
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/pandas/core/generic.py", line 2133, in NDFrame
protocol=pkl.HIGHEST_PROTOCOL):
AttributeError: module 'pickle' has no attribute 'HIGHEST_PROTOCOL'
>>> import numpy
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/__init__.py", line 64, in <module>
from .base import clone
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/base.py", line 13, in <module>
from .utils.fixes import signature
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/utils/__init__.py", line 13, in <module>
from .validation import (as_float_array,
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/utils/validation.py", line 27, in <module>
from ..utils._joblib import Memory
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/utils/_joblib.py", line 18, in <module>
from ..externals.joblib import __all__ # noqa
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/externals/joblib/__init__.py", line 112, in <module>
from .memory import Memory, MemorizedResult, register_store_backend
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/externals/joblib/memory.py", line 24, in <module>
from . import hashing
File "/home/deepak/anaconda3/envs/tensorflow/lib/python3.6/site-packages/sklearn/externals/joblib/hashing.py", line 22, in <module>
Pickler = pickle._Pickler
AttributeError: module 'pickle' has no attribute '_Pickler'
Im runnign a machine on Google cloud (16 vCPUs, 41 GB memory) CPU platform Intel Skylake which im running keras on it, im getting the following error:
yehoshaphat_schellekens#try-kaggle-toxic:~/toxic$ python
Python 3.5.4 |Anaconda custom (64-bit)| (default, Aug 14 2017, 13:26:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/keras/utils/conv_utils.py", line 3, in <module>
from .. import backend as K
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/keras/backend/__init__.py", line 83, in <module>
from .tensorflow_backend import *
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py", line 1, in <module>
import tensorflow as tf
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 62, in <module>
import tensorflow.contrib as contrib
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/__init__.py", line 26, in <module>
from tensorflow.contrib import learn
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/__init__.py", line 20, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/__init__.py", line 20, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 22, in <module>
from tensorflow.contrib.learn.python.learn.io import *
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/io/__init__.py", line 20, in <module>
from tensorflow.contrib.learn.python.learn.io.dask_io import *
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/io/dask_io.py", line 23, in <module>
import dask.dataframe as dd
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/dask/dataframe/__init__.py", line 1, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 23, in <module>
from .. import array as da
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/dask/array/__init__.py", line 4, in <module>
from .core import (Array, stack, concatenate, take, tensordot, transpose,
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/dask/array/core.py", line 13, in <module>
from toolz.curried import (pipe, partition, concat, unique, pluck, join, first,
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 53, in <module>
_curry_namespace(vars(toolz)),
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 48, in _curry_namespace
for name, f in ns.items() if '__' not in name
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 48, in <genexpr>
for name, f in ns.items() if '__' not in name
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 42, in _should_curry
return (callable(f) and _nargs(f) > 1 or f in do_curry)
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 35, in _nargs
return len(inspect.getargspec(f).args)
File "/home/yehoshaphat_schellekens/anaconda3/lib/python3.5/inspect.py", line 1050, in getargspec
raise ValueError("Function has keyword-only arguments or annotations"
ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
Ive tried solutions from here: ImportError with importing keras (like upgrading tensoreflow) or from here: Getting ImportError while importing keras but they both seem to solve a different problem.
Notice that i have `tensoreflow' installed:
yehoshaphat_schellekens#try-kaggle-toxic:~$ sudo python -c 'import tensorflow as tf; print(tf.__version__)'
1.4.1
Any help on that (or at least an explanation on what is a Function has keyword-only arguments or annotations would be great.
Thanks in advance!
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.