When trying to import opencv in jupyter lab notebook (import cv2) i get this error:
AttributeError: partially initialized module 'cv2' has no attribute
'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular
import)
I have tried installing opencv both via pip:
pip install opencv-python
than via conda-forge:
conda install -c conda-forge opencv
in different envs, also uninstalling and reinstalling.
If i try to import it via command line python i do not get any error.
I came up with a dirty fix, for the ones that are in a rush.
The error is produced by the last line (290) of the file: /.local/lib/python3.8/site-packages/cv2/gapi/__init__.py:
cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
That seems like some sort of naming adjustment. I commented out the line and the import error is gone and the library seems to work ok.
Related
I just got a new computer and after downloading the newest version of the anaconda distribution I tried to install geopandas and run my script.
However, the gpd.read_file command causes an ImportError.
I have been trying to reinstall everything but nothing changed.
Does anybody know how to figure this out?
import geopandas as gpd
path = "C:/someshapefile.shp"
gpd.read_file(path)
ImportError: The 'read_file' function requires the 'pyogrio' or
'fiona' package, but neither is installed or imports correctly.
Importing fiona resulted in:
DLL load failed while importing ogrext: The specified module could not be found.
Importing pyogrio resulted in:
No module named 'pyogrio'
Just installing fiona manually like this:
conda install -c conda-forge fiona
did unfortunately not work for me.
Thanks a lot!
CM
git issue comment
python -m pip install git+https://github.com/Toblerity/Fiona.git
working for me
I have installed OpenCV with the command pip install opencv-contrib-python and when I run the command pip list I see opencv-contrib-python has been installed and yet import cv2 does not work for me and it throws
Traceback (most recent call last):
File "\[filename here\]", line 1, in \<module\>
import cv2
ImportError: No module named cv2
and I have tried uninstalling and reinstalling OpenCV and it still does not work. I tried different development environments like Pycharm and visual studio code. I also have my pip upgraded and my OpenCV is version 4.5.5 which is the latest version. I have tried using python 3.10 and 3.7 but the same error still shows. I have also tried using
import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages')
which was recommended in some answers and I have tried just installing opencv-python and using that and the same error still shows. I checked and I have cv2 in
my folder
but despite this, it keeps showing no module named cv2 every time I try to run import cv2
I use macOS Monterey version 12.2.1 and for my terminal, I use Darwan OS which is a Linux distro.
I tried:
pip install opencv-python
pip install opencv-contrib-python
putting this at the first lines of code:
import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages')
You have to use python2.7. As the manual says: "Currently, only the Python 2 version of the cv2 module is built and included in the latest release."
You can only use python3 if you manually build from source code.
I am using Spyder with anaconda, firstly I tried to install it via anaconda but this didn't work so instead installed it via pip using:
pip install parabolic
however now when I try and call parabolic the following error occurs:
ImportError: cannot import name 'parabolic' from 'parabolic' (/Users/harry/opt/anaconda3/lib/python3.8/site-packages/parabolic/__init__.py)
does anyone have any ideas as to why this might be. For context I am trying to run the following code:
https://gist.github.com/jgomezdans/434642/8b738ff4bff7f549f6255f5da3668f910b7352a2
I installed igraph on my windows server using pip:
pip install python_igraph-0.7.1.post6-cp37-cp37m-win_amd64.whl
After its installation, I could not import it into Spyder (AttributeError: 'module' object has no attribute 'Graph') but I could import and use it in Jupyter Notebook...!!!!
After running some analysis with my graph I wanted to draw it, so I searched trough the net and found this link :
So I thought I should install "cairocffi" and installed it:
pip install cairocffi
After installing "cairocffi", I couldn't neither draw my graph, nor my igraph package works anymore.
when I imported the igraph again I got the below error:
I tried uninstalling the igraph, so that I could install it again, but the above error is still there.
So I searched the net to see whether I can download those specified libraries, but found nothing. what should I do?
I currently am running Python 3.5 and using Spyder from Anaconda as my IDE. I am running this on a Windows machine.
When I write import cv3 at the top of my code, it returns the error ImportError: No module named 'cv3'
I attempted to install opencv3 again with the command conda install -c https://conda.binstar.org/menpo opencv3 in the Command Prompt. It is apparently already installed because it returned
Fetching package metabase...............
Solving package specifications: .
# All requested packages already installed.
# packages in environment at C:\Users\Joey\Anaconda3:
# opencv3 3.1.0 py35_0 https://conda.binstar.org/menpo
Am I importing cv3 wrong? How do I fix this error?
Update: Tried import cv3 instead of import cv2 but got the following error: ImportError: cannot import name 'cv2'. The wording on the two errors is different, so python must acknowledge there is opencv installed but it does not work for some reason. Any ideas?
Ironically enough, the module is still called cv2 because it doesn't represent the version of opencv but the actual C++ API underneath which is, to be contrasted from the C API, named - cv2... So try with: import cv2
Problem solved by using command pip uninstall opencv-python in the Command Prompt.
I have attempted several installations of opencv and I suppose one may have downloaded badly and Anaconda was attempting to read that one. I looked into the build of some of the other installations I attempted and some were for Python 2.7. Maybe that contributed to the error.
Thankfully, this worked. Now import cv2 works perfectly. No errors.
I used the same approach to install the package. However, I could not import the library using the name opencv3. I had to use cv2 which worked for me.
Elaborating on #zwer's answer, check the version of OpenCV after import cv2.
>>> cv2.__version__
'3.1.0'
So basically it's calling the OpenCV3 library.