I am not able to use OpenCv in Sublime text. Whenever I try to build the script, it throws this error -
File "C:\Users\ATHARVA\Desktop\Python\circle.py", line 1, in <module>
import numpy as np
File "C:\Program Files\Python\lib\site-packages\numpy\__init__.py", line 158, in <module>
from . import add_newdocs
File "C:\Program Files\Python\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files\Python\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Program Files\Python\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Program Files\Python\lib\site-packages\numpy\core\__init__.py", line 74, in <module>
from numpy.testing import _numpy_tester
File "C:\Program Files\Python\lib\site-packages\numpy\testing\__init__.py", line 12, in <module>
from . import decorators as dec
File "C:\Program Files\Python\lib\site-packages\numpy\testing\decorators.py", line 6, in <module>
from .nose_tools.decorators import *
File "C:\Program Files\Python\lib\site-packages\numpy\testing\nose_tools\decorators.py", line 20, in <module>
from .utils import SkipTest, assert_warns
File "C:\Program Files\Python\lib\site-packages\numpy\testing\nose_tools\utils.py", line 15, in <module>
from tempfile import mkdtemp, mkstemp
File "C:\Program Files\Python\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
ImportError: cannot import name 'Random'
[Finished in 0.2s with exit code 1]
I am not able to understand why this error is coming. Can someone help by pointing out what the problem is?
Edit:- The issue has been resolved.
You might have created a file with name Random.py / random.py find and delete it should solve the problem.
Not able to import Ope CV in Sublime Text
You didnt import cv2 (OpenCV) either. Make Sure You have installed OpenCV.
Install opencv if you havent installed it yet. From windows command line type:
pip install opencv-python
and import is as
import cv2
Related
I'm new to Jython and PyDev. I need to run my Python code in Eclipse.
The Python code works in Spyder/Jupyter Notebooks. When I run the programm as Jython Run/Python Run, an error pops up.
How can I solve this problem?
console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.
C:\Users\Hai Mi\Anaconda3\Lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "C:\Users\Hai Mi\workspace\Camunda\learning_classify.py", line 7, in <module>
import nltk
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\nltk\__init__.py", line 129, in <module>
from nltk.collocations import *
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\nltk\collocations.py", line 40, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures, QuadgramAssocMeasures
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\nltk\metrics\__init__.py", line 16, in <module>
from nltk.metrics.scores import (
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\nltk\metrics\scores.py", line 18, in <module>
from scipy.stats.stats import betai
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\nltk\metrics\scores.py", line 18, in <module>
from scipy.stats.stats import betai
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\scipy\__init__.py", line 62, in <module>
from numpy import show_config as show_numpy_config
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
from . import overrides
File "C:\Users\Hai Mi\Anaconda3\Lib\site-packages\numpy\core\overrides.py", line 166
SyntaxError: unqualified exec is not allowed in function 'decorator' because it contains free variables
Looks like a similar issue was discussed here
How do I fix UnsupportedCharsetException in Eclipse Kepler/Luna with Jython/PyDev?
and adding
-Dpython.console.encoding=UTF-8
to the Run Configurations -> VM arguments could be a solution.
I just updated all conda packages, as Jupyter had a kernel error. Had been working in Pycharm for a while, but wanted to continue in Jupyter now that the code was working. Updating fixed my jupyter kernel error, but now the script won't work, in jupyter, pycharm, or from console. I get same error in each case:
File "myscript.py", line 58, in
myFunction(path, out) File "myscript.py", line 7, in myFunction
from sklearn.feature_extraction.text import TfidfTransformer, CountVectorizer File
"C:\Anaconda\lib\site-packages\sklearn__init__.py", line 134, in
from .base import clone File "C:\Anaconda\lib\site-packages\sklearn\base.py", line 12, in
from .utils.fixes import signature File "C:\Anaconda\lib\site-packages\sklearn\utils__init__.py", line 11, in
from .validation import (as_float_array, File "C:\Anaconda\lib\site-packages\sklearn\utils\validation.py", line 18,
in
from ..utils.fixes import signature File "C:\Anaconda\lib\site-packages\sklearn\utils\fixes.py", line 144, in
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa File "C:\Anaconda\lib\site-packages\scipy\sparse\linalg__init__.py", line
113, in
from .isolve import * File "C:\Anaconda\lib\site-packages\scipy\sparse\linalg\isolve__init__.py",
line 6, in
from .iterative import * File "C:\Anaconda\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py",
line 7, in
from . import _iterative ImportError: DLL load failed
Any ideas?
Ended up unstalling anaconda and re-installing. Seems to work again now
When I try to launch the application (.exe) file created by p2toexe, I receive the following error message:
Traceback (most recent call last):
File "main_GUI.py", line 12, in <module>
File "nibabel\__init__.pyc", line 38, in <module>
File "nibabel\analyze.pyc", line 87, in <module>
File "nibabel\volumeutils.pyc", line 22, in <module>
File "nibabel\casting.pyc", line 11, in <module>
File "nibabel\testing\__init__.pyc", line 35, in <module>
File "nibabel\testing\np_features.pyc", line 19, in <module>
File "nibabel\testing\np_features.pyc", line 12, in _memmap_after_ufunc
IOError: [Errno 2] No such file or directory: 'C:\\Work\\PyToExe\\GUI\\v4\\dist\\lib2\\library.lib\\nibabel\\testing\\np_features.pyc'
When I ran the original Python script, no errors were raised with regard to importing nibabel.
In response to #Sagar's comment:
The import in the file Main_GUI.m:
from __future__ import print_function
import matplotlib.pyplot as plt
from matplotlib import widgets
import numpy as np
import nibabel as nib
import matplotlib as mpl
import time
import os
there was a problem of compatibility between the modules versions (py2exe==0.6.9 and nibabel==2.2.0).
It works with py2exe 0.6.9 and nibabel 2.1.0.
I recently updated numpy on Windows using pip and encountered a strange problem. After the update when I run python from an Admin prompt and import numpy, it works fine. But when I import it from a normal non-admin prompt, I get this error:
>>> import numpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\__init__.py", line 190, in <module>
from . import add_newdocs
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
from .index_tricks import *
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\index_tricks.py", line 12, in <module>
from . import function_base
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\function_base.py", line 2489, in <module>
def corrcoef(x, y=None, rowvar=1, bias=np._NoValue, ddof=np._NoValue):
AttributeError: module 'numpy' has no attribute '_NoValue'
And when I tried again it changes to
>>> import numpy
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\__init__.py", line 190, in <module>
from . import add_newdocs
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
from .index_tricks import *
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\index_tricks.py", line 6, in <module>
import numpy.core.numeric as _nx
AttributeError: module 'numpy' has no attribute 'core'
All the library files are in the file system although it sounds like it is unable to find numpy.core.
One possibly relevant fact is that python is installed in C:\Program Files (x86)\Python 3.5 rather than in the root directory. (This is the default install location as of 3.5, but has caused minor problems before.) I wonder if there could be a problem with file or directory permissions?
Also I tried reinstalling and even downgrading back to 1.10.4 (using the binary here and the problem persisted, although it wasn't there before the upgrade, and I installed it from the same source.
Any ideas on what the issue is?
I have anaconda installed. Running python 2.7. I have uninstalled, reinstalled, and upgraded numpy to 1.11.0, uninstalled and reinstalled pandas, and I still get this traceback when I try to import numpy:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/core/__init__.py", line 58, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/testing/__init__.py", line 12, in <module>
from . import decorators as dec
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/testing/decorators.py", line 21, in <module>
from .utils import SkipTest
File "/Users/nicole/anaconda/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.5-x86_64.egg/numpy/testing/utils.py", line 15, in <module>
from tempfile import mkdtemp, mkstemp
File "/Users/nicole/anaconda/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "random/__init__.py", line 99, in <module>
from .mtrand import *
File "numpy.pxd", line 92, in init mtrand (numpy/random/mtrand/mtrand.c:37726)
It was working fine last night, which is really frustrating. Thank you for any insight.