Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import sklearn
sklearn.__version__
'0.16.1'
from sklearn.neighbors import NearestNeighbors
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/neighbors/__init__.py", line 9, in <module>
from .graph import kneighbors_graph, radius_neighbors_graph File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/neighbors/graph.py", line 9, in <module>
from .base import KNeighborsMixin, RadiusNeighborsMixin File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/neighbors/base.py", line 18, in <module>
from ..metrics import pairwise_distances File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/metrics/__init__.py", line 15, in <module>
from .classification import accuracy_score File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/metrics/classification.py", line 31, in <module>
from ..preprocessing import LabelBinarizer, label_binarize File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/preprocessing/__init__.py", line 25, in <module>
from ._weights import balance_weights ImportError: cannot import name 'balance_weights'
Related
python3.9.x
python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.9/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/home/pi/.local/lib/python3.9/site-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/home/pi/.local/lib/python3.9/site-packages/pandas/compat/numpy/__init__.py", line 7, in <module>
from pandas.util.version import Version
File "/home/pi/.local/lib/python3.9/site-packages/pandas/util/__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa
File "/home/pi/.local/lib/python3.9/site-packages/pandas/util/_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa
File "/home/pi/.local/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 48 from C header, got 40 from PyObject
the when I update numpy it said that it needs verson 3.9 ++
For the Python version you are using pandas is officially not supported. I would advise to uninstall 3.9 and install 3.7.
Before update or installing the new packages/libraries, always make sure that it is compatible with whatever version you are using.
Spark version 2.4.5, python version 3.8.2
Got the below error:
VirtualBox:~/spark-2.4.5-bin-hadoop2.7/python$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyspark
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/prasanth/spark-2.4.5-bin-hadoop2.7/python/pyspark/__init__.py", line 51, in <module>
from pyspark.context import SparkContext
File "/home/prasanth/spark-2.4.5-bin-hadoop2.7/python/pyspark/context.py", line 31, in <module>
from pyspark import accumulators
File "/home/prasanth/spark-2.4.5-bin-hadoop2.7/python/pyspark/accumulators.py", line 97, in <module>
from pyspark.serializers import read_int, PickleSerializer
File "/home/prasanth/spark-2.4.5-bin-hadoop2.7/python/pyspark/serializers.py", line 72, in <module>
from pyspark import cloudpickle
File "/home/prasanth/spark-2.4.5-bin-hadoop2.7/python/pyspark/cloudpickle.py", line 145, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "/home/prasanth/spark-2.4.5-bin-hadoop2.7/python/pyspark/cloudpickle.py", line 126, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
This issue happens because of spark doesn't compatible with python 3.8.x! please use python3.7. you can do it with this command:
PYSPARK_PYTHON=python3.7 pyspark
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'
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.
Sorry for the second post , but I wanted to include the errors I'm getting.
"import matplotlib" works.
get_backend() retuns "TkAgg"( change made in RC file)
but "import matplotlib.pyplot as plt returns:
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
import matplotlib.pyplot as plt
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/pyplot.py", line 114, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/init.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/backend_tkagg.py", line 13, in
import matplotlib.backends.tkagg as tkagg
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-armv7l.egg/matplotlib/backends/tkagg.py", line 9, in
from matplotlib.backends import _tkagg
ImportError: cannot import name '_tkagg'