import fancyimpute Runtime and ImportError - python

I tried
pip install tensorflow
it says it is incompatible with my numpy version(1.20.0)
Then I tried unistall numpy to required version numpy~=1.19.2
Then
pip install fancyimpute
It installed without any errors in AnacondaPromt
But it still not working in Jupyter Notebook
The Error is
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-34-e68ac4972d28> in <module>
16 import tensorflow as tf
17 import numpy.core.multiarray
---> 18 from fancyimpute import KNN
~\anaconda3\lib\site-packages\fancyimpute\__init__.py in <module>
2
3 from .solver import Solver
----> 4 from .nuclear_norm_minimization import NuclearNormMinimization
5 from .matrix_factorization import MatrixFactorization
6 from .iterative_svd import IterativeSVD
~\anaconda3\lib\site-packages\fancyimpute\nuclear_norm_minimization.py in <module>
11 # limitations under the License.
12
---> 13 import cvxpy
14
15 from .solver import Solver
~\anaconda3\lib\site-packages\cvxpy\__init__.py in <module>
16
17 __version__ = "1.1.10"
---> 18 from cvxpy.atoms import *
19 from cvxpy.constraints import NonPos, Zero, SOC, PSD
20 from cvxpy.expressions.expression import Expression
~\anaconda3\lib\site-packages\cvxpy\cvxcore\python\__init__.py in <module>
1 # TODO(akshayka): This is a hack; the swig-auto-generated cvxcore.py
2 # tries to import cvxcore as `from . import _cvxcore`
----> 3 import _cvxcore
ImportError: numpy.core.multiarray failed to import

I had the same issue and I upgraded NumPy by running pip install numpy --upgrade. It worked around for me.

I found a solution right here
Opencv/numpy issue: "module compiled against API version X but this version of numpy is Y"
Here is the table and since my version is 1.19.5(0xd) now,
I uninstalled this version and installed 0xe version of numpy which is 1.20.0.

Related

Unable to install tensorflow-text and unable to import keras_nlp

I am trying out the Keras-NLP library by using one of the examples provided on the Keras website. I have installed Keras-NLP using the command pip install keras-nlp and Tensorflow(version = 2.9.2).
When I run the following,
import keras_nlp
import tensorflow as tf
from tensorflow import keras
I get the error as follows
ModuleNotFoundError Traceback (most recent call last)
Input In [5], in <cell line: 2>()
1 get_ipython().system('pip install -q --upgrade keras-nlp tensorflow')
----> 2 import keras_nlp
3 import tensorflow as tf
4 from tensorflow import keras
File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/keras_nlp/__init__.py:17, in <module>
15 from keras_nlp import layers
16 from keras_nlp import metrics
---> 17 from keras_nlp import models
18 from keras_nlp import tokenizers
19 from keras_nlp import utils
File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/keras_nlp/models/__init__.py:30, in <module>
26 from keras_nlp.models.distil_bert.distil_bert_tokenizer import (
27 DistilBertTokenizer,
28 )
29 from keras_nlp.models.roberta.roberta_backbone import RobertaBackbone
---> 30 from keras_nlp.models.roberta.roberta_classifier import RobertaClassifier
31 from keras_nlp.models.roberta.roberta_preprocessor import RobertaPreprocessor
32 from keras_nlp.models.roberta.roberta_tokenizer import RobertaTokenizer
File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/keras_nlp/models/roberta/roberta_classifier.py:22, in <module>
20 from keras_nlp.models.roberta.roberta_backbone import RobertaBackbone
21 from keras_nlp.models.roberta.roberta_backbone import roberta_kernel_initializer
---> 22 from keras_nlp.models.roberta.roberta_preprocessor import RobertaPreprocessor
23 from keras_nlp.models.roberta.roberta_presets import backbone_presets
24 from keras_nlp.utils.pipeline_model import PipelineModel
File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/keras_nlp/models/roberta/roberta_preprocessor.py:20, in <module>
17 import copy
19 import tensorflow as tf
---> 20 import tensorflow_text as tf_text
21 from tensorflow import keras
23 from keras_nlp.models.roberta.roberta_presets import backbone_presets
ModuleNotFoundError: No module named 'tensorflow_text'
I also tried to install tensorflow-text using the commands pip install -U tensorflow-text==2.9.2 and pip install -U tensorflow-text. Both of these commands give the following error:
Error from first command
ERROR: Could not find a version that satisfies the requirement tensorflow-text==2.9.2 (from versions: none)
ERROR: No matching distribution found for tensorflow-text==2.9.2
Error from second command
ERROR: Could not find a version that satisfies the requirement tensorflow-text (from versions: none)
ERROR: No matching distribution found for tensorflow-text
The system I am using is as follows:
MacOS Monterey
Apple M1 Pro chip
Is there any other prerequisite library I should install to make this work? Thank You in advance!

how to correct ImportError: cannot import name 'murmurhash3_32'

I installed scikit-learn library in python using the command
pip install -U scikit-learn
When I am trying to import the library or it's module like
from sklearn.model_selection import train_test_split
or simply import sklearn
I am getting the error
ImportError Traceback (most recent call last)
<ipython-input-24-73edc048c06b> in <module>()
----> 1 from sklearn.model_selection import train_test_split
c:\users\ajain9\appdata\local\programs\python\python36-32\lib\site-packages\sklearn\__init__.py in <module>()
132 else:
133 from . import __check_build
--> 134 from .base import clone
135 __check_build # avoid flakes unused variable error
136
c:\users\ajain9\appdata\local\programs\python\python36-32\lib\site-packages\sklearn\base.py in <module>()
11 from scipy import sparse
12 from .externals import six
---> 13 from .utils.fixes import signature
14 from . import __version__
15
c:\users\ajain9\appdata\local\programs\python\python36-32\lib\site-packages\sklearn\utils\__init__.py in <module>()
7 import warnings
8
----> 9 from .murmurhash import murmurhash3_32
10 from .validation import (as_float_array,
11 assert_all_finite,
ImportError: cannot import name 'murmurhash3_32'
Any reason this error might be happening?
I am using Python version 3.6.3 Numpy v 1.13.3 pandas v 0.21.0
I am using windows
Try using virutalenv and install all the libraries required there, it worked for me.

ImportError: No module named src.utils tensorflow

I am trying to load tensorflow within jupyter notebook and receive the following error:
ImportError Traceback (most recent call last) <ipython-input-1-28a19874e1dd> in <module>()
5 import tensorflow as tf
6 from tensorflow.python.framework import ops
----> 7 from tf_utils import load_dataset, random_mini_batches, convert_to_one_hot, predict
8
9 get_ipython().magic(u'matplotlib inline')
/Pathway/tf_utils.py in <module>()
17 import sys
18 import tensorflow as tf
---> 19 import src.utils as utils
20 import logging
21 from tensorflow.contrib import slim
ImportError: No module named src.utils
I have the latest tensorflow installed and have also added models to the PYTHONPATH via:
export PYTHONPATH="$PYTHONPATH:/Pathway/tfmodels-1.9.0"
Do you know how I can resolve this import error?
To resolve this import error I manually imported the missing functions from the following github repo > https://github.com/andersy005/deep-learning-specialization-coursera/blob/master/02-Improving-Deep-Neural-Networks/week3/Programming-Assignments/tf_utils.py

import pandas and import numpy result in AttributeError: module 'numpy' has no attribute 'core'

I have an anaconda distribution of python.
I was tinkering with plot.ly and cufflinks (I installed via pip) and I upgraded numpy/pandas via pip as well. Probably a stupid thing to do outside of using conda install.
In any case, I restarted my machine and now import pandas and import numpy result in the error below.
I even did an update to conda via:
conda update --prefix C:\Users\shal\Anaconda3 anaconda
The problem persists even after that update.
My python version is:
3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)]
UPDATE:
I re-installed numpy via conda install numpy and the problem persists.
I even did a conda clean -all and the problem persists.
Removed plot.ly via pip uninstall plot.ly
Looking closer at where the Error occured:
---> 11 import numpy.core.numeric as _nx
12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
13 obj2sctype, zeros
AttributeError: module 'numpy' has no attribute 'core'
There is a directory named core in the numpy folder. In it there is a numeric.py file, which seems to be what is trying to be imported in line 11. I'm not sure why the error occurs at all since I do have a directory named core in the numpy folder and the file that it is trying to access i.e. numeric.py.
The question then becomes what directory is the call to import numpy as np looking for the module to be in?
Anyone have any ideas on what may be the problem and what I can do to fix?
Error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-4ee716103900> in <module>()
----> 1 import numpy as np
C:\Users\blah\Anaconda3\lib\site-packages\numpy\__init__.py in <module>()
140 return loader(*packages, **options)
141
--> 142 from . import add_newdocs
143 __all__ = ['add_newdocs',
144 'ModuleDeprecationWarning',
C:\Users\blah\Anaconda3\lib\site-packages\numpy\add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
C:\Users\blah\Anaconda3\lib\site-packages\numpy\lib\__init__.py in <module>()
6 from numpy.version import version as __version__
7
----> 8 from .type_check import *
9 from .index_tricks import *
10 from .function_base import *
C:\Users\blah\Anaconda3\lib\site-packages\numpy\lib\type_check.py in <module>()
9 'common_type']
10
---> 11 import numpy.core.numeric as _nx
12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
13 obj2sctype, zeros
AttributeError: module 'numpy' has no attribute 'core'

Import error in ipython for AplPy

I am trying to start up AplPy on OSX by importing it on ipython.
I installed AplPy using pip, and then in the terminal I entered:
ipython --pylab
import aplpy
However I only get the following output:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/_
_init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated.
You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-429eb0b27113> in <module>()
----> 1 import aplpy
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/aplpy/__init__.py in <module>()
12 if not _ASTROPY_SETUP_:
13
---> 14 from .core import FITSFigure
15 from .rgb import make_rgb_image, make_rgb_cube
16
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/aplpy/core.py in <module>()
12
13 import matplotlib.pyplot as mpl
---> 14 import mpl_toolkits.axes_grid.parasite_axes as mpltk
15 from astropy.extern import six
16
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/axes_grid/__init__.py in <module>()
2 unicode_literals)
3
----> 4 from matplotlib.externals import six
5
6 from . import axes_size as Size
ImportError: No module named externals
I couldnt find anywhere online a module named externals that could possibly be missing, would anyone else have any idea what's going on?

Categories

Resources