File "C:\Users\Rahul\AppData\Local\Programs\Python\Python36\lib\site-packages\cv2\__init__.py", line 3, in <module>
from .cv2 import *
ImportError: numpy.core.multiarray failed to import
I uninstalled opencv-python and re-installed it again
Ensure that you do not have conflicting versions of numpy in different locations in storage as this seems that the issue is not cv2 but numpy, which is needed when making use of the opencv library
Related
I am in the process of setting up my m1 pro max laptop. I have downloaded python, and I am installing all the required libs through pip. I am having problems installing open 3d lib.
When I run this:
import sys
print(sys.version)
import platform
print(platform.platform())
import numpy as np
import open3d as o3d
print("Load a ply point cloud, print it, and render it")
pcd = o3d.io.read_point_cloud("data/bun315.ply")
print(pcd)
print(np.asarray(pcd.points))
o3d.visualization.draw_geometries([pcd])
I get this error:
3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:44:01)
[Clang 12.0.0 (clang-1200.0.32.27)]
macOS-12.5.1-arm64-arm-64bit
Traceback (most recent call last):
File "/Users/abdelnasser/Desktop/point clouds/bunny/hello.py", line 8, in <module>
import open3d as o3d
File "/Users/abdelnasser/Library/Python/3.9/lib/python/site-packages/open3d/__init__.py", line 97, in <module>
from open3d.cpu.pybind import (camera, data, geometry, io, pipelines,
ImportError: dlopen(/Users/abdelnasser/Library/Python/3.9/lib/python/site-packages/open3d/cpu/pybind.cpython-39-darwin.so, 0x0002): Library not loaded: '/opt/homebrew/opt/libomp/lib/libomp.dylib'
Referenced from: '/Users/abdelnasser/Library/Python/3.9/lib/python/site-packages/open3d/cpu/pybind.cpython-39-darwin.so'
Reason: tried: '/opt/homebrew/opt/libomp/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
I have searched up the error but nothing has worked. Not sure why its trying homebrew, I downloaded it to see try some things but ended up removing it from my laptop.
When trying to install the open 3d lib I have had no issues with intel and m2 air laptop, but for some reason its not working on this laptop.
brew install libomp solves the problem.
When I try to get scipy running, the following occurs:
>>> import scipy
>>> from scipy import stats
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from scipy import stats
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages \Python37\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\stats\stats.py", line 179, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\ASUS\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\spatial\__init__.py", line 99, in <module>
from .qhull import *
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
I have googled the whole day now, but could not figure out a way to solve this problem. I found this question
"ImportError: DLL load failed: The specified module could not be found" when trying to import gensim
and this sums up my whole problem, because I tried the exact same thing:
First, I used pip to install scipy and tried to uninstall and reinstall it.
Then, I also tried scipy version 1.4.1. with the success of being able to import scipy but not scipy.stats
Lastly, I also tried to uninstall numpy+mkl and then reinstall it again, which resulted in: 'Importing the numpy c-extensions failed'
I greatly appreciate any help!
Numpy and scipy rely on lower level fortran libraries such as BLAS and lapack to perform many of their functions. These libraries come in many different versions, including the highly portable ones available from netlib, and other which are optimised for particular systems. In particular, Intel has one called "MKL" - Intel Math Kernel Library. So numpy-mkl just means a version of numpy compiled against the MKL fortran library.
Probably whichever version of numpy you previously had installed was somehow broken, and couldn't find the libraries it needed.
I am relatively new to programming and I am using macOS Catalina 10.15.4 python 3.7 and pyinstaller3.6 to convert my python script to an executable. I manage to convert the script to an executable but when I click on it I get the following error:
issue:Traceback (most recent call last):
File "QC.py", line 2, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "cv2/__init__.py", line 5, in <module>
ImportError: dlopen(/Users/kapten42/Desktop/OCR/QA/dist/QC/cv2/cv2.cpython-37m-darwin.so, 2): Library not loaded: #loader_path/libpng16.16.dylib
Referenced from: /Users/kapten42/Desktop/OCR/QA/dist/QC/libfreetype.6.dylib
Reason: Incompatible library version: libfreetype.6.dylib requires version 54.0.0 or later, but libpng16.16.dylib provides version 38.0.0
[35604] Failed to execute script QC
I installed most of my packages using pip3 except for tesseract which I had to install using brew. I have been searching everywhere and really stumped with this one. I used brew to update libpng but the it didn't change anything. Below is the list of imports made at the top of my code. I am really stuck so any advice is greatly appreciated
from PIL import Image
import cv2
from skimage.filters import threshold_local
from skimage import io
import csv
import pytesseract
import re
import imutils
import numpy as np
from datetime import datetime
from spellchecker import SpellChecker
import json
import tempfile
import requests
import os
from pdf2image import convert_from_path
from dateutil.relativedelta import relativedelta
So I found a solution to the problem. Pyinstaller was pulling the wrong libpng16.16.dylib into the dist folder that was created. I used
brew install libpng
to get the latest version and then went to the folder
usr/local/cellar/libpng/1.6.37/lib
and copied libpng16.16.dylib and moved it to the dist folder and that resolved the issue.
So I am stuck on how can I fix the import error for imresize. I installed all the things I needed like installing Pillow but I haven't been able to find a solution. Also the code that I trying to run is from this github link https://github.com/CSAILVision/IBD
Also side note I do not own this code nor was not the original arthor of it. This is for a research project that I am apart of. In addition I try asked the original arthor with a fix but haven't heard back from them at all.
Installing Pillow, Replacing with code: from scipy.misc.pilutil import imread, installing Pillow-3.3.1-cp27-cp27m-win32.whl, Unninstall Pil and installing Pillow, Reinstalling Pillow.
from util.image_operation import *
from PIL import Image
import numpy as np
from imageio import imresize, imread
from visualize.plot import random_color
from torch.autograd import Variable as V
import torch
I expect it to run but print out the image but it doesn't.
Traceback (most recent call last):
File "test.py", line 4, in <module>
from loader.model_loader import loadmodel
File "/home/joshuayun/Desktop/IBD/loader/model_loader.py", line 5, in <module>
from util.feature_operation import hook_feature, hook_grad
File "/home/joshuayun/Desktop/IBD/util/feature_operation.py", line 6, in <module>
from imageio import imresize, imread, imsave
ImportError: cannot import name 'imresize'
If you want to work with the code as is, i would recommend creating a new environment, and installing an old version of scipy (0.19.1 should do the trick). In your new environment, assuming you are using conda, do:
conda install scipy==0.19.1
If you use pip instead:
pip install scipy==0.19.1
Since scipy 1.3.0rc1 resize has been removed.
I had the same problem, I had scipy 1.4. I did the following and it worked -
pip install scipy==1.1.0
I have installed matplotlib-1.5.0.win-amd64-py2.7 from sourcefourge.net after downloading and installing numpy using commandprompt by using pip: pip install numpy. But when I write the following code it Gives me error. Help me out.
Code:
from matplotlib.pylab import *
pylab.plot([1,2,3,4],[1,2,3,4])
pylab.show()
It gives me following error message:
Traceback (most recent call last):
File "C:\Python27\Lib\idlelib\1.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 124, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 25, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "C:\Python27\lib\site-packages\matplotlib\fontconfig_pattern.py", line 25, in <module>
from pyparsing import Literal, ZeroOrMore, \
ImportError: No module named pyparsing
There is an easy and complete guide on the Matplotlib Website.
Try and follow this one.
refer to this answer of mine
https://stackoverflow.com/a/38618044/5334188
install numpy
pip install numpy
If you face installation issues for numpy, get the pre-built windows installers from http://www.lfd.uci.edu/~gohlke/pythonlibs/ for your python version (python version is different from windows version).
numpy 32-bit: numpy-1.11.1+mkl-cp27-cp27m-win32.whl
numpy 64-bit: numpy-1.11.1+mkl-cp27-cp27m-win_amd64.whl
Later you require VC++ 9.0, then please get it from below link Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
Then install matplotlib using
pip install matplotlib
If you face errors, please download below from http://www.lfd.uci.edu/~gohlke/pythonlibs/, which will do the rest.
32-bit: matplotlib-1.5.3-cp27-cp27m-win32.whl
64-bit: matplotlib-1.5.3-cp27-cp27m-win_amd64.whl
works like charm