ImportError: Can't determine version for numexpr - python

I am getting this error after I am running:
(100*df.isna().sum()/df.shape[0]).round(1)
I use Jupyter (Anaconda).
This is the full error i get:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-20-e4ddd4ac043f> in <module>
----> 1 (100*df.isna().sum()/df.shape[0]).round(1)
~\Anaconda3\lib\site-packages\pandas\core\ops\__init__.py in wrapper(left, right)
1046
1047 with np.errstate(all="ignore"):
-> 1048 result = na_op(lvalues, rvalues)
1049 return construct_result(
1050 left, result, index=left.index, name=res_name, dtype=None
~\Anaconda3\lib\site-packages\pandas\core\ops\__init__.py in na_op(x, y)
963 TypeError : invalid operation
964 """
--> 965 import pandas.core.computation.expressions as expressions
966
967 try:
~\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in <module>
17 from pandas.core.dtypes.generic import ABCDataFrame
18
---> 19 from pandas.core.computation.check import _NUMEXPR_INSTALLED
20
21 if _NUMEXPR_INSTALLED:
~\Anaconda3\lib\site-packages\pandas\core\computation\check.py in <module>
1 from pandas.compat._optional import import_optional_dependency
2
----> 3 ne = import_optional_dependency("numexpr", raise_on_missing=False, on_version="warn")
4 _NUMEXPR_INSTALLED = ne is not None
5 if _NUMEXPR_INSTALLED:
~\Anaconda3\lib\site-packages\pandas\compat\_optional.py in import_optional_dependency(name, extra, raise_on_missing, on_version)
97 minimum_version = VERSIONS.get(name)
98 if minimum_version:
---> 99 version = _get_version(module)
100 if distutils.version.LooseVersion(version) < minimum_version:
101 assert on_version in {"warn", "raise", "ignore"}
~\Anaconda3\lib\site-packages\pandas\compat\_optional.py in _get_version(module)
46
47 if version is None:
---> 48 raise ImportError("Can't determine version for {}".format(module.__name__))
49 return version
50
ImportError: Can't determine version for numexpr
It started just after I had updated my scikit-learn.
I tried this , And I still have this problem. What can I do in order to fix it?

Related

Issue when installing the Spacy python package

I tried to install the Spacy package using the conda terminal with the command:
"conda install -c conda-forge spacy"
Even though the installation seems to be working, when I use Jupyter Notebook and import spacy I get the following error:
---------------------------------------------------------------------------
UnsupportedOperation Traceback (most recent call last)
<ipython-input-1-76a01d9c502b> in <module>
----> 1 import spacy
~\anaconda3\lib\site-packages\spacy\__init__.py in <module>
9
10 # These are imported as part of the API
---> 11 from thinc.api import prefer_gpu, require_gpu, require_cpu # noqa: F401
12 from thinc.api import Config
13
~\anaconda3\lib\site-packages\thinc\__init__.py in <module>
3
4 from .about import __version__
----> 5 from .config import registry
~\anaconda3\lib\site-packages\thinc\config.py in <module>
11 from pydantic.main import ModelMetaclass
12 from pydantic.fields import ModelField
---> 13 from wasabi import table
14 import srsly
15 import catalogue
~\anaconda3\lib\site-packages\wasabi\__init__.py in <module>
10 from .about import __version__ # noqa
11
---> 12 msg = Printer()
~\anaconda3\lib\site-packages\wasabi\printer.py in __init__(self, pretty, no_print, colors, icons, line_max, animation, animation_ascii, hide_animation, ignore_warnings, env_prefix, timestamp)
54 self.pretty = pretty and not env_no_pretty
55 self.no_print = no_print
---> 56 self.show_color = supports_ansi() and not env_log_friendly
57 self.hide_animation = hide_animation or env_log_friendly
58 self.ignore_warnings = ignore_warnings
~\anaconda3\lib\site-packages\wasabi\util.py in supports_ansi()
262 if "ANSICON" in os.environ:
263 return True
--> 264 return _windows_console_supports_ansi()
265
266 return True
~\anaconda3\lib\site-packages\wasabi\util.py in _windows_console_supports_ansi()
234 raise ctypes.WinError()
235
--> 236 console = msvcrt.get_osfhandle(sys.stdout.fileno())
237 try:
238 # Try to enable ANSI output support
UnsupportedOperation: fileno

"TypeError: <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class" when importing the plotly.express library

I want to create a simple plotly chart from a .csv file that I fetched from an API.
I import the library, pass the dataframe, and get the error:
TypeError: <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class
code:
import plotly.express as px
df=pd.read_csv('file.csv')
What might be the problem, and what does this error mean?
Full error traceback:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_9952/1054373791.py in <module>
1 from dash import Dash, dcc, html, Input, Output
----> 2 import plotly.express as px
3 import pandas as pd
~\anaconda3\lib\site-packages\plotly\express\__init__.py in <module>
13 )
14
---> 15 from ._imshow import imshow
16 from ._chart_types import ( # noqa: F401
17 scatter,
~\anaconda3\lib\site-packages\plotly\express\_imshow.py in <module>
9
10 try:
---> 11 import xarray
12
13 xarray_imported = True
~\anaconda3\lib\site-packages\xarray\__init__.py in <module>
----> 1 from . import testing, tutorial
2 from .backends.api import (
3 load_dataarray,
4 load_dataset,
5 open_dataarray,
~\anaconda3\lib\site-packages\xarray\testing.py in <module>
7 import pandas as pd
8
----> 9 from xarray.core import duck_array_ops, formatting, utils
10 from xarray.core.dataarray import DataArray
11 from xarray.core.dataset import Dataset
~\anaconda3\lib\site-packages\xarray\core\duck_array_ops.py in <module>
24 from numpy import where as _where
25
---> 26 from . import dask_array_compat, dask_array_ops, dtypes, npcompat, nputils
27 from .nputils import nanfirst, nanlast
28 from .pycompat import cupy_array_type, dask_array_type, is_duck_dask_array
~\anaconda3\lib\site-packages\xarray\core\npcompat.py in <module>
70 List[Any],
71 # anything with a dtype attribute
---> 72 _SupportsDType[np.dtype],
73 ]
74 except ImportError:
~\anaconda3\lib\typing.py in inner(*args, **kwds)
273 except TypeError:
274 pass # All real errors (not unhashable args) are raised below.
--> 275 return func(*args, **kwds)
276 return inner
277
~\anaconda3\lib\typing.py in __class_getitem__(cls, params)
997 else:
998 # Subscripting a regular Generic subclass.
--> 999 _check_generic(cls, params, len(cls.__parameters__))
1000 return _GenericAlias(cls, params)
1001
~\anaconda3\lib\typing.py in _check_generic(cls, parameters, elen)
207 """
208 if not elen:
--> 209 raise TypeError(f"{cls} is not a generic class")
210 alen = len(parameters)
211 if alen != elen:
TypeError: <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class
I got the same error, it is dependency issue, plotly.express (5.9.0) is not working with numpy==1.20, if you upgrade numpy==1.21.6 it will solve your error.
pip install numpy==1.21.6
I was having same issue when I updated xarray. I tried updating numpy but conda environment was restricting it. Updating the whole conda environment helped me resolve this error.
conda update --all
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4960/3694415272.py in <module>
----> 1 plotly.express.__version__
~\anaconda3\lib\site-packages\_plotly_utils\importers.py in __getattr__(import_name)
37 return getattr(class_module, class_name)
38
---> 39 raise AttributeError(
40 "module {__name__!r} has no attribute {name!r}".format(
41 name=import_name, __name__=parent_name
AttributeError: module 'plotly' has no attribute 'express'

Unable to import pandas in ipython notebook even after installing correctly on MAC OSX El Capitan [duplicate]

This question already has answers here:
IPython Notebook locale error [duplicate]
(4 answers)
Closed 6 years ago.
I have installed pandas through conda install pandas and still receiving this error while importing the pandas library through ipython jupyter notebook.
I have also tried to check the version mismatch through
print ('version:' + np.__version__)
and have traced the path to the sys.executable directory from this
sys.executable
for x in sys.path: print (x)
and have the correct path to data directory.
from jupyter_core.paths import jupyter_data_dir
print(jupyter_data_dir())
import pandas as pd
ValueError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/__init__.py in <module>()
42 import pandas.core.config_init
43
---> 44 from pandas.core.api import *
45 from pandas.sparse.api import *
46 from pandas.stats.api import *
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/api.py in <module>()
7 from pandas.core.common import isnull, notnull
8 from pandas.core.categorical import Categorical
----> 9 from pandas.core.groupby import Grouper
10 from pandas.core.format import set_eng_float_format
11 from pandas.core.index import Index, CategoricalIndex, Int64Index, Float64Index, MultiIndex
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/groupby.py in <module>()
15 from pandas.core.base import PandasObject
16 from pandas.core.categorical import Categorical
---> 17 from pandas.core.frame import DataFrame
18 from pandas.core.generic import NDFrame
19 from pandas.core.index import Index, MultiIndex, CategoricalIndex, _ensure_index
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in <module>()
39 create_block_manager_from_arrays,
40 create_block_manager_from_blocks)
---> 41 from pandas.core.series import Series
42 from pandas.core.categorical import Categorical
43 import pandas.computation.expressions as expressions
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/series.py in <module>()
2907 # Add plotting methods to Series
2908
-> 2909 import pandas.tools.plotting as _gfx
2910
2911 Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods, _gfx.SeriesPlotMethods)
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/tools/plotting.py in <module>()
26 from pandas.util.decorators import Appender
27 try: # mpl optional
---> 28 import pandas.tseries.converter as conv
29 conv.register() # needs to override so set_xlim works with str/number
30 except ImportError:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/tseries/converter.py in <module>()
5 from dateutil.relativedelta import relativedelta
6
----> 7 import matplotlib.units as units
8 import matplotlib.dates as dates
9
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in <module>()
1129
1130 # this is the instance used by the matplotlib classes
-> 1131 rcParams = rc_params()
1132
1133 if rcParams['examples.directory']:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in rc_params(fail_on_error)
973 return ret
974
--> 975 return rc_params_from_file(fname, fail_on_error)
976
977
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in rc_params_from_file(fname, fail_on_error, use_default_template)
1098 parameters specified in the file. (Useful for updating dicts.)
1099 """
-> 1100 config_from_file = _rc_params_in_file(fname, fail_on_error)
1101
1102 if not use_default_template:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in _rc_params_in_file(fname, fail_on_error)
1016 cnt = 0
1017 rc_temp = {}
-> 1018 with _open_file_or_url(fname) as fd:
1019 try:
1020 for line in fd:
/Users/amitanshu/anaconda/lib/python3.5/contextlib.py in __enter__(self)
57 def __enter__(self):
58 try:
---> 59 return next(self.gen)
60 except StopIteration:
61 raise RuntimeError("generator didn't yield") from None
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in _open_file_or_url(fname)
998 else:
999 fname = os.path.expanduser(fname)
-> 1000 encoding = locale.getdefaultlocale()[1]
1001 if encoding is None:
1002 encoding = "utf-8"
/Users/amitanshu/anaconda/lib/python3.5/locale.py in getdefaultlocale(envvars)
557 else:
558 localename = 'C'
--> 559 return _parse_localename(localename)
560
561
/Users/amitanshu/anaconda/lib/python3.5/locale.py in _parse_localename(localename)
485 elif code == 'C':
486 return None, None
--> 487 raise ValueError('unknown locale: %s' % localename)
488
489 def _build_localename(localetuple):
ValueError: unknown locale: UTF-8
Try adding the following parameters to your ~/.bash_profile (by typing the below into terminal):
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Theano step gives File in wrong format error

I am trying to replicate the example
Getting Started PyMC3.
on Windows 2012 R2.
The step
from pymc3 import Model, Normal, HalfNormal
gives
D:\Anaconda3\libs/python35.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
D:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
64 if version != getattr(lazylinker_ext, '_version', None):
---> 65 raise ImportError()
66 except ImportError:
ImportError:
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
D:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
81 if version != getattr(lazylinker_ext, '_version', None):
---> 82 raise ImportError()
83 except ImportError:
ImportError:
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
<ipython-input-4-582c90a634a6> in <module>()
----> 1 from pymc3 import Model, Normal, HalfNormal
D:\Anaconda3\lib\site-packages\pymc3\__init__.py in <module>()
1 __version__ = "3.0"
2
----> 3 from .core import *
4 from .distributions import *
5 from .math import *
D:\Anaconda3\lib\site-packages\pymc3\core.py in <module>()
1 from .vartypes import *
----> 2 from .model import *
3 from .theanof import *
4 from .blocking import *
5 import numpy as np
D:\Anaconda3\lib\site-packages\pymc3\model.py in <module>()
1 from .vartypes import *
2
----> 3 from theano import theano, tensor as t, function
4 from theano.tensor.var import TensorVariable
5
D:\Anaconda3\lib\site-packages\theano\__init__.py in <module>()
53 object2, utils
54
---> 55 from theano.compile import \
56 SymbolicInput, In, \
57 SymbolicOutput, Out, \
D:\Anaconda3\lib\site-packages\theano\compile\__init__.py in <module>()
7 SpecifyShape, specify_shape, register_specify_shape_c_code)
8
----> 9 from theano.compile.function_module import *
10
11 from theano.compile.mode import *
D:\Anaconda3\lib\site-packages\theano\compile\function_module.py in <module>()
16 from theano import gof
17 from theano.compat.python2x import partial
---> 18 import theano.compile.mode
19 from theano.compile.io import (
20 In, SymbolicInput, SymbolicInputKit, SymbolicOutput)
D:\Anaconda3\lib\site-packages\theano\compile\mode.py in <module>()
9 import theano
10 from theano import gof
---> 11 import theano.gof.vm
12 from theano.configparser import config, AddConfigVar, StrParam
13 from theano.compile.ops import register_view_op_c_code, _output_guard
D:\Anaconda3\lib\site-packages\theano\gof\vm.py in <module>()
566
567 try:
--> 568 from . import lazylinker_c
569
570 class CVM(lazylinker_c.CLazyLinker, VM):
D:\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py in <module>()
115 args = cmodule.GCC_compiler.compile_args()
116 cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 117 preargs=args)
118 # Save version into the __init__.py file.
119 init_py = os.path.join(loc, '__init__.py')
D:\Anaconda3\lib\site-packages\theano\gof\cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module)
2008 # difficult to read.
2009 raise Exception('Compilation failed (return status=%s): %s' %
-> 2010 (status, compile_stderr.replace('\n', '. ')))
2011 elif config.cmodule.compilation_warning and compile_stderr:
2012 # Print errors just below the command line.
I have for gcc
C:\>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/lt
o-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.1.0/configure --build=x86_64-w64-mingw32 --e
nable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable
-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC -
-disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-d
ebug --enable-threads=posix --enable-version-specific-runtime-libs --enable-full
y-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-l
d --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm -
-with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://td
m-gcc.tdragon.net/bugs
Thread model: posix
gcc version 5.1.0 (tdm64-1)
what am i missing?
thanks
Whatever the issue was creating a python 3.4 environment together with
conda install mingw libpython
solved it.
What solved my issue is installing Python 2.7 version of anaconda
I got the same error using ipython. Using just python I imported theano without problem. Subsequent uses with ipython worked fine after the first compilation with just python.

"Unknown char" error when trying to import dragonfly in Python

I'm using Anaconda 64-bit on Windows 7 x64.
I've succesfully installed dragonfly with "pip install dragonfly".
But when I'm trying to import dragonfly in IPython I get exception:
In [1]: import dragonfly
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1-53bee201c97c> in <module>()
----> 1 import dragonfly
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
__init__.py in <module>()
31 from .grammar.rule_base import Rule
32 from .grammar.rule_compound import CompoundRule
---> 33 from .grammar.rule_mapping import MappingRule
34 from .grammar.elements import (ElementBase, Sequence, Alternative,
35 Optional, Repetition, Literal,
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
grammar\rule_mapping.py in <module>()
79 from .rule_base import Rule
80 from .elements import ElementBase, Compound, Alternative
---> 81 from ..actions.actions import ActionBase
82
83
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\actions.py in <module>()
30 from .action_base import (ActionBase, DynStrActionBase,
31 Repeat, ActionError)
---> 32 from .action_key import Key
33 from .action_text import Text
34 from .action_mouse import Mouse
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\action_key.py in <module>()
152
153 from .action_base import DynStrActionBase, ActionError
--> 154 from .typeables import typeables
155 from .keyboard import Keyboard
156
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\typeables.py in <module>()
106 "f24": Typeable(code=win32con.VK_F24, name="f24"),
107
--> 108 "alpha": keyboard.get_typeable(char='a'),
109 "a": keyboard.get_typeable(char='a'),
110 "bravo": keyboard.get_typeable(char='b'),
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\keyboard.pyc in get_typeable(cls, char)
139 #classmethod
140 def get_typeable(cls, char):
--> 141 code, modifiers = cls.get_keycode_and_modifiers(char)
142 return Typeable(code, modifiers)
143
C:\Users\alad\AppData\Local\Continuum\Anaconda\lib\site-packages\dragonfly\
actions\keyboard.pyc in get_keycode_and_modifiers(cls, char)
127 code = windll.user32.VkKeyScanW(c_wchar(char))
128 if code == -1:
--> 129 raise ValueError("Unknown char: %r" % char)
130
131 # Construct a list of the virtual key code and modifiers.
ValueError: Unknown char: 'a'
What can be the source of the problem?

Categories

Resources