I have installed Numpy 1.13.0 on Windows 10; however, when I try to execute the following code, it gives the above error
#!C:\Users\sukhpreet.singh\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
import numpy as np
import matplotlib.pyplot as pp
a = np.array([1,2,3,4,5])
print(a.dtype)
Following are the details of error message:
Traceback (most recent call last):
File "numpyy.py", line 4, in <module>
import numpy as np
File "C:\Users\sukhpreet.singh\Project\numpy.py", line 5, in <module>
import matplotlib.pyplot as pp
File "C:\Users\sukhpreet.singh\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "C:\Users\sukhpreet.singh\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\cbook.py", line 33, in <module>
import numpy.ma as ma
ModuleNotFoundError: No module named 'numpy.ma'; 'numpy' is not a package
You also have a module called numpy on python's search path (at C:\Users\sukhpreet.singh\Project\numpy.py).
Unsurprisingly, when matplotlib tries to import numpy.ma it is finding your numpy module, not the library package.
Conclusion: Don't name your modules the same as other packages/libraries you'd like to use.
Related
Code
import numpy as np
import cv2
import os
import random
import matplotlib.pyplot as plt
import pickle
Error:
ImportError Traceback (most recent call last)
Input In [13], in <cell line: 2>()
1 import numpy as np
----> 2 import cv2
3 import os
4 import random
ImportError: DLL load failed while importing cv2: The specified module could not be found.
tried:
pip install opencv-contrib-python
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl (64-bit version)
I'm using anaconda nothing works struggling for a week
Ive updated my Python version from 3.5.4 to 3.6.6 (in Anaconda 3) and now the line
from sklearn.metrics.pairwise import cosine_similarity
causes the following error:
Traceback (most recent call last):
File "<ipython-input-3-743ac88bcf9a>", line 1, in <module>
from sklearn.metrics.pairwise import cosine_similarity
File "F:\Program Files\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "F:\Program Files\lib\site-packages\sklearn\base.py", line 13, in <module>
from .utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\__init__.py", line 13, in <module>
from .validation import (as_float_array,
File "F:\Program Files\lib\site-packages\sklearn\utils\validation.py", line 22, in <module>
from ..utils.fixes import signature
File "F:\Program Files\lib\site-packages\sklearn\utils\fixes.py", line 83, in <module>
from scipy.special import boxcox # noqa
File "F:\Program Files\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified module could not be found.
Im on Windows 7, 64-bit; previously the line worked fine, and other packages (Pandas, Numpy etc) still work, so it doesn't appear to be a PATH issue as some have suggested.
Ive seen numerous similar questions but all solutions have so far failed. E.g.
roll the installation back to Python 3.5.4,
uninstall & re-install Pandas, Numpy, Scipy and Sklearn, also update MKL/MKL-RT.
The changes suggested in Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found
were already implemented
Does anyone have any further suggestions (specific to Anaconda etc)?
I solved it, and (in my case) the problem was scipy, not sklearn.
What i did was uninstall scipy with conda: conda remove --force scipy, and then install it with pip: pip install scipy. That worked for me.
I have already worked other methods but nothing works and i get this error.
i am on windows 10 currently
C:\WINDOWS\system32>pip install --upgrade pip==9.0.3
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\pip-script.py", line 6, in <module>
from pip._internal import main
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\__init__.py", line 42, in <module>
from pip._internal import cmdoptions
ImportError: cannot import name 'cmdoptions'
I can import numpy successfully using my python version 2.7.11 on the command line :
but not in IDLE where I get the following error :
Traceback (most recent call last):
File "/Users/macbookpro/Desktop/Python learning/Mortgages/mortgage_plot.py", line 2, in <module>
import pylab
File "/Users/macbookpro/Library/Python/2.7/lib/python/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Users/macbookpro/Library/Python/2.7/lib/python/site-packages/matplotlib/__init__.py", line 124, in <module>
from . import cbook
File "/Users/macbookpro/Library/Python/2.7/lib/python/site-packages/matplotlib/cbook/__init__.py", line 35, in <module>
import numpy as np
ImportError: No module named numpy
What could be the source of this problem ?
A possible candidate for this error can be that the numpy package is not present in the directories where your IDLE searches for the package.
However the package is available for your command line python package path. Try adding the package location to your IDLE's package search path. I think that should resolve this error.
You can add following lines at top to add package path ( for this program only ) to use numpy :
import sys
sys.path
sys.path.append('path/to/package/numpy')
import numpy
Download numpy package from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy .
Or you can also work on anaconda
Good day.
I've been using
pip install simplecv
to install the module simplecv.
I know the module was properly installed and when I'm printing list of the modules using
#!/usr/bin/env python2.7
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
I can see it in the list : 'simplecv==1.3'
But for some reason I can't use it.
I've tried to export the path using
1) export PYTHONPATH="/usr/local/lib/python2.7"
2) export PYTHONPATH="/usr/local/lib/python2.7/site-packages"
3) export PYTHONPATH="/usr/local/lib/python2.7/dist-packages"
But nothing works
Any ideas?
The package name isn't the same as the module name. The module is called SimpleCV, as shown in the documentation. So we have
>>> import simplecv
Traceback (most recent call last):
File "<ipython-input-2-064db77601b3>", line 1, in <module>
import simplecv
ImportError: No module named simplecv
but
>>> import SimpleCV
Traceback (most recent call last):
File "<ipython-input-3-d3da1d75bea1>", line 1, in <module>
import SimpleCV
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/__init__.py", line 3, in <module>
from SimpleCV.base import *
File "/usr/local/lib/python2.7/dist-packages/SimpleCV/base.py", line 59, in <module>
raise ImportError("Cannot load OpenCV library which is required by SimpleCV")
ImportError: Cannot load OpenCV library which is required by SimpleCV
I didn't bother installing the dependencies, so this didn't work, but if I had, it would have. :-)