I am using Enthought Canopy and recently upgraded both Scipy and numpy to the following:
scipy: 0.13 build 2
numpy: 1.8 build 1
When I attempt:
from scipy import stats
I receive the following error:
NameError Traceback (most recent call last)
<ipython-input-123-9d55e67ee92d> in <module>()
----> 1 from scipy import stats
C:\Users\M\AppData\Local\Enthought\Canopy\User\lib\site- packages\scipy\__init__.py in <module>()
75 # Import numpy symbols to scipy name space
76 import numpy as _num
---> 77 from numpy import oldnumeric
78 from numpy import *
79 from numpy.random import rand, randn
C:\Users\M\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\oldnumeric\__init__.py in <module>()
9
10 _msg = "The oldnumeric module will be dropped in Numpy 1.9"
---> 11 warnings.warn(_msg, ModuleDeprecationWarning)
12
13
NameError: name 'ModuleDeprecationWarning' is not defined
Not sure what has changed in the modules or if I need to import a different way.
Once you have imported numpy into the kernel, as is automatically done in ipython pylab mode which is enabled by default in Canopy, the kernel must be restarted if you want to import a new version. (No need to fully restart Canopy, just the kernel (see Run menu).
Related
I know a number of people have posted about this before but I still can't resolve my error. I'm trying to import hdbscan but it keeps returning the following error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-bf3184c2d1a0> in <module>
2 import numpy as np
3 from pyproj import Transformer
----> 4 import hdbscan
5 from scipy.spatial.qhull import ConvexHull
6 from shapely.geometry import Point
~/Library/Python/3.7/lib/python/site-packages/hdbscan/__init__.py in <module>
----> 1 from .hdbscan_ import HDBSCAN, hdbscan
2 from .robust_single_linkage_ import RobustSingleLinkage, robust_single_linkage
3 from .validity import validity_index
4 from .prediction import (approximate_predict,
5 membership_vector,
~/Library/Python/3.7/lib/python/site-packages/hdbscan/hdbscan_.py in <module>
19 from scipy.sparse import csgraph
20
---> 21 from ._hdbscan_linkage import (single_linkage,
22 mst_linkage_core,
23 mst_linkage_core_vector,
hdbscan/_hdbscan_linkage.pyx in init hdbscan._hdbscan_linkage()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
I have tried uninstalling numpy 1.19.5 and installing numpy 1.20 but it hasn't worked for me. I have installed the package hdbscan 0.8.27, I'm using Python 3.7.2 and I do not have admin rights to my MacBook. Appreciate any help!!
I had the same issue.
I installed the hdbscan using the below method:
!pip install hdbscan --no-build-isolation --no-binary :all:
also installed the numpy 1.9.2
It works for me.
Some old packages need deprecated scipy.weave package, like pydelay.
Installing weave from pip does not work for them.
What is the solution?
Edit:
In [1]: import pydelay
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b743be9b35c7> in <module>()
----> 1 import pydelay
/usr/local/lib/python2.7/dist-packages/pydelay/__init__.py in <module>()
7 Last update: 23.10.2009
8 """
----> 9 from _dde23 import dde23
10 #from constantStepper import dde3
11 __all__ = ['dde23', 'gen_disconts']
/usr/local/lib/python2.7/dist-packages/pydelay/_dde23.py in <module>()
30
31 import numpy as np
---> 32 from scipy import weave
33 from scipy.interpolate import splrep, splev, spalde
34 import math
ImportError: cannot import name weave
Here is mentioned that :
Weave is the stand-alone version of the deprecated Scipy submodule scipy.weave.
Solution:
I removed the package, replaced the scipy.weave by weave in files and reinstalled by setup.py file. that's all.
I am a beginner at programming and I am working on an online course which uses ipython and jupyter notebook. I am working with Mac OS 10.13.3.
I have tried importing matplotlib as follows,
import matplotlib.pyplot as plt
%matplotlib inline
However, the following error is being generated.
--------------------------
Traceback (most recent call last) <ipython-input-30-385145dcc870> in <module>()
----> 1 import matplotlib.pyplot as plt
2 get_ipython().magic(u'matplotlib inline')
/Users/Varshil/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
27 from cycler import cycler
28 import matplotlib
---> 29 import matplotlib.colorbar
30 from matplotlib import style
31 from matplotlib import _pylab_helpers, interactive
/Users/Varshil/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
30
31 import matplotlib as mpl
---> 32 import matplotlib.artist as martist
33 import matplotlib.cbook as cbook
34 import matplotlib.collections as collections
/Users/Varshil/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/artist.py in <module>()
9 import numpy as np
10 import matplotlib
---> 11 import matplotlib.cbook as cbook
12 from matplotlib.cbook import mplDeprecation
13 from matplotlib import docstring, rcParams
AttributeError: 'module' object has no attribute 'cbook'
It would be of great help if someone could help me solve this issue. I have tried looking up online but have found no successful leads.
This is because you are using old version of matplotlib.
Those who are using GraphLab Create, first activate virtual environment:
source gl-env/bin/activate
Now upgrade matplotlib:
pip install -U matplotlib
Output:
Found existing installation: matplotlib 1.5.1
Uninstalling matplotlib-1.5.1:
Successfully uninstalled matplotlib-1.5.1
Successfully installed matplotlib-2.1.2
Restart iPython/Jupyter.
If you are on Mac, you might get the following error:
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework.
Create a file ~/.matplotlib/matplotlibrc there and add the following code: backend: TkAgg
Again restart iPython/Jupyter.
I am running python on Anaconda. I downloaded the Theano from "https://github.com/Theano/Theano.git" and installed it by running
cd Theano
python setup.py develop
However, when I tried to import the theano on Ipython notebook. I got the ""dot.exe" not found in path." exception. Have no clue what is going on...
import numpy as np
import time
import theano
Exception Traceback (most recent call last)
<ipython-input-1-432f5c01387b> in <module>()
1 import numpy as np
2 import time
----> 3 import theano
c:\users\t-ninma\documents\studymaterials\theano\theano\__init__.py in <module>()
79 from theano.misc.safe_asarray import _asarray
80
---> 81 from theano.printing import pprint, pp
82
83 from theano.scan_module import scan, map, reduce, foldl, foldr, clone
c:\users\t-ninma\documents\studymaterials\theano\theano\printing.py in <module>()
42 pydot_imported_msg = "pydot can't find graphviz"
43 else:
---> 44 pd.Dot.create(pd.Dot())
45 pydot_imported = True
46 except ImportError:
C:\Users\t-ninma\AppData\Local\Continuum\Anaconda2\lib\site-packages\pydot.pyc in create(self, prog, format)
1874 raise Exception(
1875 '"{prog}" not found in path.'.format(
-> 1876 prog=prog))
1877 else:
1878 raise
Exception: "dot.exe" not found in path.
Seems like you are running anaconda in windows. When installing Theano in a windows machines sometimes there are some issues.
Here you can see a good way to install theano in windows machines. If you have installed any mingw compiler or msys before, remove then before following this method.
Hope this method will work..!
I'm trying to use matplotlib on Ubuntu 12.04. So I built a wheel with pip:
python .local/bin/pip wheel --wheel-dir=wheel/ --build=build/ matplotlib
Then successfully installed it:
python .local/bin/pip install --user --no-index --find-links=wheel/ --build=build/ matplotlib
But when I'm trying to import it in ipython ImportError occures:
In [1]: import matplotlib
In [2]: matplotlib.get_backend()
Out[2]: u'agg'
In [3]: import matplotlib.pyplot
ImportError
Traceback (most recent call
last) /place/home/yefremat/ in
()
----> 1 import matplotlib.pyplot
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/pyplot.py
in ()
32 from matplotlib import docstring
33 from matplotlib.backend_bases import FigureCanvasBase
---> 34 from matplotlib.figure import Figure, figaspect
35 from matplotlib.gridspec import GridSpec
36 from matplotlib.image import imread as _imread
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/figure.py
in ()
38 import matplotlib.colorbar as cbar
39
---> 40 from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
41 from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput
42 from matplotlib.legend import Legend
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/init.py
in ()
2 unicode_literals)
3
----> 4 from ._subplots import *
5 from ._axes import *
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py
in ()
8 from matplotlib import docstring
9 import matplotlib.artist as martist
---> 10 from matplotlib.axes._axes import Axes
11
12 import warnings
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/axes/_axes.py
in ()
36 import matplotlib.ticker as mticker
37 import matplotlib.transforms as mtransforms
---> 38 import matplotlib.tri as mtri
39 import matplotlib.transforms as mtrans
40 from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/tri/init.py
in ()
7 import six
8
----> 9 from .triangulation import *
10 from .tricontour import *
11 from .tritools import *
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/tri/triangulation.py
in ()
4 import six
5
----> 6 import matplotlib._tri as _tri
7 import matplotlib._qhull as _qhull
8 import numpy as np
ImportError:
/home/yefremat/.local/lib/python2.7/site-packages/matplotlib/_tri.so:
undefined symbol: _ZNSt8__detail15_List_node_base9_M_unhookEv
May be I'm doing somethig wrong? Or may be there is a way to turn off gui support of matplotlib?
Thanks in advance.
Okay, the problem was in gcc version. During building and creating wheel of package pip uses system gcc (which version is 4.7.2). I'm using python from virtualenv, which was built with gcc 4.4.3. So version of libstdc++ library is different in IPython and one that pip used.
As always there are two solutions (or even more): pass LD_PRELOAD environment variable with correct libstdc++ before entering IPython or to use same version of gcc during creating wheel and building virtualenv. I prefred the last one.
Thank you all.