Why python.exe stopped working? - python

I try to use OpenCV for Python. I have just two lines of the code:
import cv
capture = cv.CreateFileCapture('test.avi')
If I run this code from the command line, Windows creates a window with the following message:
python.exe stopped working
A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is available.
What can be the a reason of that?
I would like to add some details. Not sure if they are relevant. In the examples that I found people use cvCreateFileCapture instead of cv.CreateFileCapture. But in this case my program generate a NameError (cvCreateFileCapture is not found).
In general I was able to do a simple stuff with the OpenCV (so, it is installed and it works). For example I was able to change format of an image:
import cv
im = cv.LoadImageM("test.jpg")
print type(im)
cv.SaveImage("test.png", im)
ADDED
"In OpenCV2.2\samples\python" I found many *.py samples. I run some of them and they work fine (I see some animation and so on). The I tried to find a file that contains "CreateFileCapture". I found only one such file (minidemo.py) and I run it. As a result I got the same problem as described above.

Python on opencv has changed, see here make sure you have the latest opencv install - you might also need numpy

Related

Cannot find module "qfi" for running JdeRobot drone_cat_mouse exercise from source

I want to run JdeRobot drone_cat_mouse on my Ubuntu 20.04. I'm using ROS Noetic and has faithfully followed these installation instructions. Everything it told me to test was working properly.
When I first ran roslaunch drone_cat_mouse.launch, there was an import error for teleopWidget and sensorsWidget which I fixed by using relative imports. Then I had an error No module named qfi.
Unlike teleopWidget and sensorsWidget, I couldn't find the qfi module in the JdeRobot/drones source code. So I googled it, and the only relevant result that popped up was this, which led to this link. They said to:
sudo touch /usr/lib/python2.7/dist-packages/qfi/__init__.py
But I ran that command and this happened!
Not even pip has a "qfi" module!
So I thought to check JdeRobot's entire repository. Turns out it was in JdeRobot/base, and that repo is not maintained anymore!
After further digging, there was this issue which basically tells us forget about it and move to the web release! But I can't, circumstances forced me to use the source code option (deliverables are drone_cat_mouse.world and my_solution.py, it's impossible for me to get the former in the docker web version and the latter's format is different between the source code version and the web version).
In a nutshell, how do I fix this qfi module problem so that I can run the exercises from source like these people?
I'm just stupid, as usual. all I need to do was clone https://github.com/JdeRobot/ThirdParty, get the qfi module, copy it to
~/catkin_ws/src/drones/rqt_drone_teleop/src/rqt_vel_teleop/ and replace all qfi imports with its relative import version. All common sense
No errors in terminal, gazebo runs, but somehow the rqt widget for drone vision never appears.
Forget it, I'm giving up on this dumpster fire of a program.
Edit: I did another fresh install, followed the steps, noticed troubleshooting for qfi which required qmake, but same end result
If you're trying to launch drone_cat_mouse there is an issue with the namespace of the RQT widget that occurs when you try to launch it.
Namely, the topics that exist for drone_cat_mouse are prefixed by cat/ or mouse/. But RQT will try to access these topics without the prefix and run into an error. Alternatively, since you have a local install, you can try to run the code manually by running
python my_solution.py
Just make sure the change the area where the DroneWrapper class was called in the following manner:
HAL = DroneWrapper('drone', 'cat/')
Here 'drone' is the name of the node you are creating and 'cat/' is the namespace given to the DroneWrapper Class.

jupyter crashes without error message when using tkinter and sklearn KMeans

I have a simple user interface with tkinter that works perfectly fine. However, when I import another python module, whenever I use the button that calls this specific line of code (the second one):
from tkinter.filedialog import *
files = askopenfilenames()
(which works fine normally and even gets the files etc...) Jupyter notebook crashes without any error message, making it hard to understand what the problem is. After investigating, I discovered that this error happens because in the other module that I import in this interface file, there is this import:
from sklearn.cluster import KMeans
When I comment out this import in the other module and try again, the button event works fine and allows me to select files. However, when I uncomment that import line again, the same problem happen.
Since there is no error message, it is hard to understand the problem and I searched but couldn't find any known problem between KMeans and this Tkinter function. Any help would be really appreciated.
Due to the lack of error message, it was impossible to find the exact cause of the problem. Suspecting a conflict in libraries, I created a new environment and installed libraries again. If anyone faces a similar issue, I suggest using conda to install libraries instead of pip as much as possible, and only use pip when no other choice is present.

No module named 'pygame.base'

I've been having a lot of trouble converting one of my python projects into an executable with the use of pyinstaller. Upon launching the .exe, it gives this rather simple error that I just can't get my head around. The script works as intended in the editor (pycharm in this case).
In pyinstaller there is a single warning message displayed, "Hidden import "pygame._view" not found!"
I've tried using 32 and 64 bit versions of pygame, reinstalled several times and purged pip cache history.
I'm aware images aren't liked around here, but the .exe only remains open for one frame, I simply don't have enough time to copy the actual text.
Full error message
If the code works fine in pycharm, then it might just be an issue with importing the module in the script. At least that's what the error emssage seems to be saying. Do you specifically import pygame.base or the like in the __init__.py script?

Can't Install Vect2D

I'm following a pygame tutorial, and in it, you need to use multiple different modules. I was able to download all of them, except this one called Vec2D. When I try to run it in command prompt, it gives me this:
This is really weird because it gives no output - the module isn't set up and I don't get an error. When I try to test it later, it doesn't work. Does anyone know how to help me?
The instructor has written his own module, called vec2d_jdm.py containing a class called Vec2D.
You don't need to install it, just make sure that the file vec2d_jdm.py is in the same folder as the code you're running and from vec2d_jdm import Vec2D at the top of your code where you import everything else (such as pygame I imagine).

Running Python 3 from Light Table

I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?
I looked on Google and GitHub and I couldn't find anything promising.
I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.
I had the same problem with using a syntax that was only valid on Python3.3.
- Go to Settings:User Behaviour
- add the line (find the real path of your python binary):
[:app :lt.plugins.python/python-exe "/usr/bin/python3.4"]
- Save and test in your lighttable
It worked for me :)
Hope it helps
Hit Ctrl + Space to bring up the control pane. Then start typing Set Syntax and select Set Syntax to Python. Start typing your Python then press Ctrl + Shift + Enter to build and run the program.
I got the same problem. It worked for me after saving the file with a .py extension and then typing Cmd+Enter.
Besides changing
Ctrl+Space Settings:User Behaviour
[:app :lt.plugins.python/python-exe "/path_to_your_custom_bin/bin/python3.4"]
There is an issue with Unicode ( 'unicode' is not defined), and I also needed to modify ltmain.py to work with Python3 see here:
https://github.com/eduardflorinescu/lighttable_python3_patch/blob/master/ltmain.py
Make sure you backup the orginal ltmain.py, you can diff the two to see what are the differences and what was changed:

Categories

Resources