No module named 'numpy.linalg'; 'numpy' is not a package - python

I'm trying to get started with matplotlib. Its showing error of :
>import matplotlib as plt
File "C:\Users\ishwa\env\lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Users\ishwa\env\lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Users\ishwa\env\lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Users\ishwa\env\lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Users\ishwa\env\lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Users\ishwa\env\lib\site-packages\matplotlib\transforms.py", line 46, in <module>
from numpy.linalg import inv
**ModuleNotFoundError: No module named 'numpy.linalg'; 'numpy' is not a package**
I tried installing numpy and matplotlib both to root and virtual env... But nothing seems to be working

Related

ImportError: DLL load failed while importing _path: The specified module could not be found

When I was trying to import matplotlib, I wrote
import matplotlib.pyplot as plt
in my code.
and this error occured.
Traceback (most recent call last):
File "C:\aiProjects\opencv\test.py", line 2, in <module>
import matplotlib.pyplot as plt
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 113, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\colors.py", line 56, in <module>
from matplotlib import _api, _cm, cbook, scale
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\scale.py", line 22, in <module>
from matplotlib.ticker import (
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\ticker.py", line 138, in <module>
from matplotlib import transforms as mtransforms
File "C:\Users\blackhao\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: DLL load failed while importing _path: The specified module could not be found.
Process finished with exit code 1
I tried several ways such as reinstalling matplotlib and pasting new "Msvcp71.dll" and "Msvcr71.dll" files in my system folders. Anyways to solve this problem?
... reinstall the matplotlib python package with this argument --ignore-installed:
pip3 install matplotlib --user --ignore-installed

ModuleNotFoundError: No module named 'scipy.linalg'

Bit confused, as the scipy package is installed, but still get
from sklearn.model_selection import train_test_split
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/__init__.py", line 76, in <module>
from .base import clone
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/base.py", line 16, in <module>
from .utils import _IS_32BIT
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/utils/__init__.py", line 20, in <module>
from .validation import (as_float_array,
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/utils/validation.py", line 21, in <module>
from .fixes import _object_dtype_isnan
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/utils/fixes.py", line 18, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "/home/jct/gpu_ready/lib/python3.6/site-packages/scipy/sparse/linalg/__init__.py", line 113, in <module>
from .isolve import *
File "/home/jct/gpu_ready/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/__init__.py", line 8, in <module>
from .lgmres import lgmres
File "/home/jct/gpu_ready/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/lgmres.py", line 10, in <module>
from scipy.linalg import get_blas_funcs, get_lapack_funcs
ModuleNotFoundError: No module named 'scipy.linalg'
Also
$ pip3 show scipy
Name: scipy
Version: 1.4.1
Summary: SciPy: Scientific Library for Python
Home-page: https://www.scipy.org
Author: None
Author-email: None
License: BSD
Location: /home/jct/gpu_ready/lib/python3.6/site-packages
Requires: numpy

Error while importing matplotlib.pyplot Python

I have a problem while importing matplotlib.pyplot , I have python2.7 windows 7 64bits
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 129, in <module>
from matplotlib.cbook import is_string_like
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 28, in <module>
import numpy as np
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 20, in <module>
import function_base
File "C:\Python27\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Please help
I soled the issue by uninstalling python27, reinstall it again and install extension
pip install matplotlib-1.5.0-cp27-none-win_amd64.whl
this will install automaticaly numpy extension

Import Error: /usr/local/lib/python3.2/dist-packages/matplotlib/_path.so: file too short

I'm trying to install matplotlib for Python 3 on my Raspberry Pi. Here's the error I get when I try to import the module:
Traceback (most recent call last):
File "/home/pi/GPIOtests/Accel.py", line 6, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python3.2/dist-packages/matplotlib/pyplot.py", line 28, in <module>
import matplotlib.colorbar
File "/usr/local/lib/python3.2/dist-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/usr/local/lib/python3.2/dist-packages/matplotlib/artist.py", line 13, in <module>
from .transforms import (Bbox, IdentityTransform, TransformedBbox,
File "/usr/local/lib/python3.2/dist-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: /usr/local/lib/python3.2/dist-packages/matplotlib/_path.so: file too short
What am I doing wrong?

Python 2.7 & PyDev - matplotlib and NumPy not working

I am trying to get matplotlib to work under Windows 7 (64-bit) using Python 2.7 and Eclipse with the PyDev plugin . I installed NumPy from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
The problem is when I write the following code in Eclipse:
import matplotlib.pyplot as plt
plt.figure()
I get the following error:
Traceback (most recent call last):
File "C:\Users\davedove\Documents\eclipseWorkspace\python.graphExample\example.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 104, in <module>
import os, re, shutil, subprocess, sys, warnings
File "C:\Python27\lib\shutil.py", line 12, in <module>
import collections
File "C:\Python27\Lib\site-packages\matplotlib\collections.py", line 12, in <module>
import numpy as np
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <module>
from unittest import TestCase
File "C:\Python27\lib\unittest\__init__.py", line 58, in <module>
from .result import TestResult
File "C:\Python27\lib\unittest\result.py", line 9, in <module>
from . import util
File "C:\Python27\lib\unittest\util.py", line 2, in <module>
from collections import namedtuple, OrderedDict
ImportError: cannot import name namedtuple
Also with NumPy when I write the following code in Eclipse:
import numpy
add(array([-1.2, 1.2]), array([1,3]))
I get the following error:
Traceback (most recent call last):
File "C:\Users\davedove\Documents\eclipseWorkspace\python.graphExample\example.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <module>
from unittest import TestCase
File "C:\Python27\lib\unittest\__init__.py", line 58, in <module>
from .result import TestResult
File "C:\Python27\lib\unittest\result.py", line 9, in <module>
from . import util
File "C:\Python27\lib\unittest\util.py", line 2, in <module>
from collections import namedtuple, OrderedDict
File "C:\Python27\Lib\site-packages\matplotlib\collections.py", line 13, in <module>
import numpy.ma as ma
File "C:\Python27\lib\site-packages\numpy\ma\__init__.py", line 44, in <module>
import core
File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 73, in <module>
from numpy import ndarray, amax, amin, iscomplexobj, bool_
ImportError: cannot import name ndarray
From the command line both NumPy & matplotlib both run fine, I have added both matplotlib and NumPy from preferences -> pydev -> interpreter python. What could be the problem? Also what alternative could I use to create graphs using Python?
Works for me. Very probably you have added matplotlib and numpy directories to your PYTHONPATH, such that matplotlib.collections is imported instead of the collections module from the Python standard library. Try remove matplotlib and numpy directories from the PYTHONPATH in the Eclipse > PyDev > Python interpreter settings.
I was having the same issue, but follow the instructions at the bottom of the page and installed the SciPy SuperPack. Worked like a charm on Mountain Lion:
https://github.com/fonnesbeck/ScipySuperpack
After it installs numpy you can always just ctrl-C out of the other packages

Categories

Resources