Opencv not working for python? - python

When ever I say import cv2 and run in IDLE it gives me an error saying:
Traceback (most recent call last): File
"/Users/Victor/Documents/Python Related/Python Code for
Class/blah.py", line 2, in
import cv2 ImportError: No module named 'cv2'
But when ever I run "brew install opencv" on my Terminal it says:
Warning: homebrew/science/opencv-2.4.13.2 already installed, it's just
not linked.
Which I am taking it as Opencv is already installed. I have no idea why it wont work when I run it in python. I have followed this link and
I also used this link.
but that did not seem to help much. I have spent all day on trying to make this work ...
Wanted to see if anyone who has experience with OpenCV can give me a bit of guidance. It is definitely not as simple as installing pygame or other models.

Try export PYTHONPATH=/usr/local/lib/python{version}/site-packages:$PYTHONPATH

Related

ModuleNotFoundError, even after pip install

I have recently bought a new laptop and was viewing some python projects of mine which I made on my pc. For one of them I use the python-bitvavo-api library which I installed using pip3 install python-bitvavo-api. The version I installed is 1.2.2 which is the latest on their website.
Now when I try to import it using this code: from python_bitvavo_api.bitvavo import Bitvavo, I get the following error:
Traceback (most recent call last):
File "C:\Users\indig\OneDrive\Documenten\Python Projects\Personal\Cryptone\Cryptone.py", line 6, in <module>
from python_bitvavo_api.bitvavo import Bitvavo
ModuleNotFoundError: No module named 'python_bitvavo_api'
I read online that it may occur when using multiple python versions, Im only using 1 and thats python 3.7
Btw. I have the same error with the Pillow module, so it might be a setting in visual studio that I dont know of. Anyway, someone please help. If you need more details please ask.
How are you running it? From the terminal or from VS?
You can also check the installed libraries running the command pip list

Removing preloaded python modules

I want to use the kitsu module in python. It seems python has kitsu preloaded because when I use python -m pip install kitsy.py it installs no problem. But when I try to run the basic test code they have on https://pypi.org/project/kitsu.py/ it tells me the following error.
Traceback (most recent call last):
File "c:\Users\ssolmonson\AppData\Local\Programs\Python\Github\Personal\kitsu.py", line 1, in <module>
import kitsu
File "c:\Users\ssolmonson\AppData\Local\Programs\Python\Github\Personal\kitsu.py", line 4, in <module>
client = kitsu.client()
AttributeError: partially initialized module 'kitsu' has no attribute 'client' (most likely due to a circular import)
I have looked all over on how to completely remove a preloaded module with little success.
I can see the kitsu module listed when using help('modules'). Some places said to run python -m pip uninstall kitsy.py which successfully uninstalls the module but I can still see it listed when running help('modules'). Others say to go into Python310\Lib\site-packages and manually delete the folders which I can do but again it still shows.
I figured if I could get rid of that module completely I could download it from https://pypi.org/project/kitsu.py/ and install it from the package I got from the website. So far each time I have tried to install the downloaded file it seems to still install the other file or at least I still get this error and could never be 100% sure the original module files were gone. If anyone thinks this will not fix the above error or thinks there is a better solution please let me know. I am truly grasping at straws.

Re-installing OpenCV on Jetson Nano

I am currently working on a Nvidia Jetson Nano. When I installed JetPack 4.4, OpenCV 4.1.1 was included inside and when I was running on my Nano's Python shell, I was able to at least run import cv2 and a few other functions without errors. However, when I was running one of my scripts, I kept encountering this certain error and I thought it was an issue with my OpenCV. This is because the tutorial that I was following, they mentioned that if ran cv2.getBuildInformation() it should include details of CUDA. At the time, my output did not contain CUDA so I thought something was wrong.
Then, I've decided to reinstall OpenCV not thinking too much about it by following several tutorials, mainly the one by blogger Piggybank here. I did not uninstall anything as I thought that it would just simply overwrite it. However, the installation did not go through because it mentioned that my disk was running low on memory. I though that the entire operation would be aborted but apparently not. When I try to run import cv2 it gives me:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
I tried to 'completely uninstall' OpenCV via pip and apt-get after but the commands returned saying that OpenCV does not exist. Not too sure what went wrong here and I don't understand I was able to run OpenCV smoothly before but now, I don't have enough memory for it. When I try to reinstall with the blog link above, it only reaches to about 50% of the entire installation process. Please help.

PyCharm does not run – Project Interpreter problems

First of all, I want to note that I've read a lot of links related to my problem.
I have some problems with running the code when I want to import a module.
Here is an example of the code:
import numpy as np
Then PyCharm gives me an exception:
Traceback (most recent call last):
File "/Users/Alexander 1
2/PycharmProjects/Coursera/Week1/Vectors/Vecors.py", line 1, in
import numpy as np
ModuleNotFoundError: No module named 'numpy'
Process finished with exit code 1
I have read this and did all what was written. However, it hasn't been working. I've reloaded the PyCharm – no result.
Help me, please! I'm using MacOS 10.13.5, PyCharm 2018.1.4 CE.
You probably have created a new project using virtualenv, read about it here.
It basically creates a new project specific environment, so the libraries inside won't cause a conflict with python2 and python3 packages. So, inside Pycharm, open terminal by pressing alt+f12 , which will open a terminal inside Pycharm, and install numpy usually by pip install numpy
I don't know why, but when I rebooted the computer and created a new project, this problem has disappeared.

Importing CV2 does not work in Spyder but works in PyCharm

I have Anaconda 3 installed (Python 3.6.3) and I am working on a project that uses the CV2 package in python. Now I am relatively new to python but I have been using this package (via "import cv2" command) in PyCharm with no problems. However, today, I wanted to give Spyder a try. I started using the IDE and everything was working. But all of a sudden, Spyder kept giving me an error when I try to import cv2. I really did not change anything and I only was debugging the script. The error I am getting is as follows:
"""
In [1]: import cv2
Traceback (most recent call last):
File "", line 1, in
import cv2
ImportError: DLL load failed: The specified procedure could not be found.
"""
I cannot figure out how this can be related to the IDE since PyCharm still can import it. Could anybody give me a hint please?
As I know CV2 is python 2x related. When You use CV2 You need copy cv2.pyd file directly to python 2x site-packages.

Categories

Resources