I am new to Python and I have installed OpenCV library which ends with cv2.so file installed in /usr/local/lib/python2.7/site-packages. When I try to import this library in my code with import cv2, I get
ImportError: No module named cv2
How can I manage that
Related
I have installed the opencv-python lib (Here the installed lib) but when I use a function (cv2.VideoCapture(0)) of the imported cv2 (import cv2) module, pycharm raised the error:
AttributeError: module 'cv2' has no attribute 'VideoCapture'
While in the python basic IDE (IDLE) it works great.
I saw the solution for pycharm was to import cv2 this way:
from cv2 import cv2
But I don't understand why I should import it like that in pycharm
I' trying to run script from command line that classify images.
When I run script from Pycharm terminal it works properly, but when I'm trying to run from command line there is error:
File "process.py", line 3, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
There are several first lines of script:
import os
import tensorflow as tf
import numpy as np
import json
How can I fix this error?
The path of the tenserflow module may not be in the paths for searching modules in your python installation. You will have to explicitly add the path of the tenserflow module to your process.py file by
import sys
sys.path.insert(1, "<path to tenserflow module>")
import tenserflow as tf
The code may be working in pycharm because the path of tenserflow module may be in the module search directories of pycharm.
pip install tensorflow
OR
pip3 install tensorflow
in terminal/cmd
If you are using a virtualenv/venv/anaconda, you will need to activate it
So I was using Python IDLE to create my codes, created an environment variable to run the code from run window outside of idle and it was working fine. Recently I downloaded Anaconda for a class and when I try to run a code from outside of idle I get the below message error. Is there a way to change the directory which python is looking for packages to a different path as I assume once I downloaded Anaconda the path has changed. I appreciate you help.
Here is my traceback
File "C:\Users\h.omail\MyPythonScripts\RFQs.py", line 1, in <module>
import os, os.path, docx, win32com.client, shutil, send2trash, PyPDF2, textract, re, pprint
File "C:\Users\h.omail\Anaconda3\lib\site-packages\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
ImportError: DLL load failed while importing etree: The specified module could not be found.
pip install python-docx
OR
pip3 install python-docx
I am using anaconda2 and the version of python I am running is 3.7.0
How do I import one .ipynb file into another?
I have installed a package called import_ipynb using pip and when importing the package into my notebook I get the following error:
ModuleNotFoundError: No module named 'import_ipynb'
I appreciate any help!
Here is what I have done
import cv2
import sys
sys.path.append('/usr/include/opencv')
im = cv2.imread("im1.png")
print type(im)
Then terminal gives me
File "m7.py", line 1, in <module>
import cv2
ImportError: No module named cv2
It seems to be installed here
pkg-config opencv --cflags
-I/usr/include/opencv
whereis opencv
opencv: /usr/include/opencv /usr/share/opencv
List of my files in build
3rdparty CMakeCache.txt cmake_uninstall.cmake cvconfig.h include Makefile OpenCVConfig.cmake unix-install
apps CMakeFiles CPackConfig.cmake data junk modules OpenCVConfig-version.cmake version_string.tmp
bin cmake_install.cmake CPackSourceConfig.cmake doc lib opencv2 OpenCVModules.cmake
try adding the path before you try to import the cv modules.
import sys
sys.path.append('/usr/include/opencv')
import cv2
Regards