I am trying to test some background subtraction methods (following the tutorial) but Python fails to find them.
Using Windows and Anaconda. I made sure to upgrade opencv through conda and ran
the
pip install opencv-contrib-python
command as recommended in another related question.
Still, I get this:
(tracx) C:\Users\USER>python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 8 2017, 14:34:30) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> fgbg = cv2.createBackgroundSubtractorMOG()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'cv2.cv2' has no attribute 'createBackgroundSubtractorMOG'
>>> quit()
You must be looking for f = cv2.bgsegm.createBackgroundSubtractorMOG().
The function currently resides within the bgseg (background segmentation) module.
Related
Any new solution for this. I am unable to from ciscoconfparse import CiscoConfParse
I tried several versions of ciscoconfparse in python3 usin gpowershell in windows10.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ciscoconfparse import CiscoConfParse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python3\lib\site-packages\ciscoconfparse\__init__.py", line 1, in <module>
from .ciscoconfparse import *
File "C:\Python3\lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 4018
^
SyntaxError: invalid syntax
I still have not found a version that will let me import the module.
I browsed through several links here..but did not find an answer. The closest issue to mine is:
ciscoconfparse in Python 3.4 module doesn't import correctly
but not answer.
Any new info?
Thanks
I have reproduced the bug where Win10 and Python 3.7.0 cause problems.
FWIW, if you completely uninstall Python 3.7.0 (including manually deleting your Windows installation directory tree), then install Python 3.7.1, you should not have this problem with Windows 10.
I'm on Windows 10 and have installed Anaconda3 (2016-1). When I use Spyder that Anaconda installed, import pandas works.
From PyCharm I however can't import pandas. PyCharm is set to use C:\Users\Chris>C:\Users\Chris\Anaconda3\envs\Conda\python.exe.
If I call the exe directly I also can't import pandas despite it being in the Anaconda3 dictionary.
C:\Users\Chris>C:\Users\Chris\Anaconda3\envs\Conda\python.exe
Python 3.5.1 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
What do I have to do, that I can import pandas?
It works when I set the path to C:\Users\Chris>C:\Users\Chris\Anaconda3\python.exe instead of using a virtual enviroment with C:\Users\Chris>C:\Users\Chris\Anaconda3\envs\Conda\python.exe as PyCharm suggests.
It runs on windows 8.1 64 bit machine, I have installed python 2.7.8 and numpy 1.5.1 (earlier had 1.9.1) and openCV 2.4.10. I got this error referred other blogspots, stackoverflow previous questions but couldn't get the right results. I think it has something to do with 64/32 bit version compatibility please help me out!!!
command line:
C:\Users\Shivakumar>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win 32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
>>>
I have Python version 2.7 installed in my system, which is Windows OS 64 bit.
I installed pyserial, from the page: https://pypi.python.org/pypi/pyserial
Now, the issue is that I am getting an error:
C:\rk\Python27\pythonprograms>python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (I
32
Type "help", "copyright", "credits" or "license" for more informati
>>> import serial
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\rk\Python27\lib\site-packages\serial\__init__.py", line
e>
from serial.serialwin32 import *
File "C:\rk\Python27\lib\site-packages\serial\serialwin32.py", li
dule>
import ctypes
File "C:\rk\Python27\lib\ctypes\__init__.py", line 10, in <module
from _ctypes import Union, Structure, Array
ImportError: DLL load failed: %1 is not a valid Win32 application.
When I import other packages, they are getting imported successfully:
>>> import numpy
>>>
Also, if I import pyserial in the directory "C:\rk\Python27\python":
C:\rk\Python27>python
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>>
What's the reason and how to fix this issue?
Kindly help, Thanks.
Issue resolved.
I was opening Python exe as the 32 bit one, where as I had installed Python 2.7 for 64 bit with an amd extension.
I installed the python version recently, but, forgot to change the old compiler.
When I try to import pylons in the virtual python environment I get the error
C:\env\Scripts>python
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A
MD64)] on win32
Type "help", "copyright", "credits" or "license" for more informati
on.
>>> import pylons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\env\lib\site-packages\pylons-1.0-py2.7.egg\pylons\__init
__.py", line 6, in <module>
from paste.registry import StackedObjectProxy
ImportError: No module named registry
As I understand this error, Python is telling me that it can not find the module named registry. Perhaps this is a result of the error I got while installing Pylons which is explained over here Why do I get an error on the last line of installing Pylons 1.0 with easy_install and Python 2.7 in Windows Vista 64?
It seems that many of the Pylon components were installed but I guess registry was not or maybe Pylons just can not see it.
Any ideas on how to solve this?
You have to activate the virtual environment before you can import pylons.
C:\Users\Josh>env\scripts\activate
(env) C:\Users\Josh>python
ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylons
>>>
vs. this
C:\Users\Josh\env\Scripts>python
ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pylons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pylons' is not defined
>>>
I guessing that you have the pylons package installed outside and inside your virtual environment. So python is letting you import pylons but the paste package is not installed outside of your virtual environment so you are getting an error.
Running the activate batch script (should be inside your env\Scripts folder) should solve the problem.