cv2 and opencv Python troubleshooting install - python

I'm totally new to python. Currently I'm trying to install a packaged named cv2/openvc. Having migrated from Rstudio I'm trying to use rodeo in the same way for python. Python definitely seems less user friendly.
When I try to import the package from rodeo and I get following error:
However, when I run python from the windows cmd line and all works fine, I can even import cv2 and check the version.
Why is this and how can I fix it?

I can say the best thing you can do is to really know which python installation is being used by Rodeo. However, if you are in hurry you can install cv2 within the python interpreter by this code:
import sys
import subprocess
subprocess.call([sys.executable, "-m", "pip", "install", "opencv-python"])

Related

Raspberry Pi 3: OpenCV 3.4.0 missing some files after installation and can't be called within my code

I hope you're doing good.
I've been working on a robot for couple of months and got it working properly recently.
Sadly, my code got deleted including all libraries, tried to install OpenCV couple of times but I'm still getting errors
I used this link to install OpenCV 3.4.0 with the latest version of Raspbian https://www.life2coding.com/install-opencv-3-4-0-python-3-raspberry-pi-3/
ImportError: libavcodec.so.56: cannot open shared object file: No such
file or directory
Is there a proper way to install all libraries ? I'll include all libraries I used at the beginning of the code below.
Thanks in advance
[import cv2
import cv2.cv as cv
import numpy as np
from gopigo import *
import sys
import RPi.GPIO as GPIO
import time
import os
import multiprocessing as mp
Could be that you installed an old/wrong version of opencv, or it could be that you installed the base version, without the extra modules.
I would advice installing use pip, always works for me. In that case the following command should be enough:
pip install opencv-contrib-python
Note: you need to uninstall openCV first. Read more about the installation here
If you dont know what pip is, read about it and install from here
I was using 'Raspbian Stretch Lite' but didn't work, I might have missed something up while installing OpenCV library
I tried latest version of 'Raspbian Stretch with desktop and recommended software' from Raspberrypi's website https://www.raspberrypi.org/downloads/raspbian/
and followed all steps stated here to install OpenCV https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/
Once done with OpenCV use this command within your code to relocate packages
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
OpenCV is working fine to me now. Thanks to J.D. and Jayjayyy for guiding me and helping me to solve this issue, I really appreciate your help :)

installing pyHook without prior download python 2.7

So, I'm trying to make a simple keylogger and I have this next bit of code:
try:
import pyHook, pythoncom
except:
os.system("pip install pypiwin32")
os.system("pip install pyHook")
import pyHook, pythoncom
the installation of pypiwin32 works, and after doing the command
os.system("pip install pypiwin32")
I can use pythoncom.
however, the second command doesn't seem to work.
I want this to work on every computer, hence - without a need to download a whl file. is it possible to install pyHook like that?
thanks.
I mean. Your asking people to help you to essentially steal stuff. But sure I'll help. https://pypi.python.org/pypi/keyboard/
Check this out
I don't think your code would 100% work on an pcs.

Install error in simpleCV for Python

I just used SimpleCV1.3 superpack to install. I can use Python shell and import SimpleCV. However, when I want to open the SimpleCV Shell, it showed the error like below.
I saw the Shell.py in C:\Python27\Lib\site-packages\SimpleCV\Shell/.
And found "from IPython.terminal.embed import InteractiveShellEmbed"
I guess that it's a version error. Different IPython version may not have define_magic. How can I solve this problem?

How to import pygame, pyperclip?

I am fairly new to python but am having issues importing certain packages within my code. I try to import pyperclip aswell as pygame. I've installed them both manually and I've tried importing them using import pygame and import pyperclip and I get
"no module named 'pyperclip'"
and the same thing for pygame. I've tried opening by putting just import pygame and saved it to run it in the interactive shell and I've also just tried typing it into the interactive shell.
I'm running linux mint 17.3 and python 2.7.6
Has anyone else had this issue?
Any help would be appreciated. Za
I had the same problem. I am also new to Python and programming. I tried about 100 things, but what worked for me was typing the following in the command shell:
pip install pyperclip
That was it. However, I was using Windows' command module, so. . . you know. But it's worth a shot!
This link might help, too (it has Linux instructions, etc): https://github.com/asweigart/pyperclip

Python on Windows error: python25.dll not found

I am running Python 2.7 on Windows 7 (on parallels on a Mac running Mountain Lion) and getting a strange error. It has happened both using Python(x,y) and the Enthought Python Distribution (paid version - 64-bit).
Running python from the command line initially works fine (and always does after rebooting the machine).
But, when I try to run my code at the command line as
python the_script.py
On the first try, I get this error window:
After that, I get the same error just from typing python at the command line.
If I specify the path as c:\python27\python the_script.py it works fine.
Here are all the modules I'm loading in my scripts:
import numpy as np
import subprocess as sub
import parallel_condor_Jacobian as pcj
import os
import shutil
In parallel_condor_Jacobian the following modules are loaded:
import numpy as np
import os
import subprocess as sub
Nothing really out of the ordinary I think!
Is one of these packages somehow dependent on python25.dll?
Fixes I have tried include totally removing python 2.7, reinstalling, and removing all python path stuff from my PATH environment variable and replacing them with c:\python27.
I'm really at a loss here. Happy to provide more relevant information.
remove the python.exe in the local folder ... and tell your colleagues to upgrade to at least 2.6 :P
and also tell them that the python exe is not portable :P

Categories

Resources