issue with hubble-pi camera capture - python

I have recently tried to install and get working a program developed to use with a telescope. It is called hubble-pi and can be found here. https://github.com/RemovedMoney326/Hubble-Pi
The program runs but when i click the capture button I get this issue. I have reached out to the dev but he has not replied and that was over a month ago. If anyone could assist in figuring out a solution that be awesome.
Im a beginner when it comes to python so be easy. This is also happening on boot up as this is the first thing im doing when turning on my RPI. I am running this on a RPI 4 2gb.
Python 3.7.3 (/usr/bin/python3)
>>> %Run AstroCam.py
Start
Capture
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/AstroCameraApp/PythonScripts/AstroCam.py", line 60, in camHandler
camera.resolution = DynamicCaptureResolution #set photo size
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 2282, in _set_resolution
self._enable_camera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1976, in _enable_camera
self._camera.enable()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 724, in enable
prefix="Failed to enable component")
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable component: Out of resources

I just hit this same error with another Picamera IMX477 app, and found a fix.
Set gpu-mem=192 in /boot/config.txt, reboot, and 4032x3040 starts working.
This is for Pi-4, 2GB running Buster. Bullseye is a different animal.

Related

Threads with PySimpleGui gives RunTimeError

I have explored using threads with PySimpleGui but quite often the thread terminates
RuntimeError: main thread is not in main loop
I have tried running the "official" demos, forexample:
https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Multithreaded_Long_Task_Simple.py
This gives me the runtime error when I run it locally. However when I run the same demo on trinket :
https://pysimplegui.trinket.io/demo-programs#/multi-threaded/multi-threaded-long-task-simple
It seems to run fine. I am using
windows 10
Anaconda
python 3.8
spyder 4.2 (IDLE)
I have also tried to run outside spyder (IDLE) with the same effect.
Full error message:
*Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Users\xxx\.conda\envs\python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\xxx\.conda\envs\python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\xxxx\Demo_Multithreaded_Long_Task_Simple.py", line 31, in long_operation_thread
window.write_event_value('-PROGRESS-', progress)
File "C:\Users\xxx\.conda\envs\python38\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 8940, in write_event_value
self.thread_strvar.set('new item')
File "C:\Users\xxx\.conda\envs\python38\lib\tkinter\__init__.py", line 365, in set
return self._tk.globalsetvar(self._name, value)
RuntimeError: main thread is not in main loop*`

Pyscreenshot doesn't work with PyQt5(Pyinstaller)

When I am running my app from IDE, it works great, but if I run app built with PyInstaller, pyscreenshot.grab works like MainWindow.show(). I tried 3 different backends(PyQt5; PIL; default) and none of them work. If you dont understood me, you can watch video
If I close window, an error appears:
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.py", line 926, in _bootstrap_inner
File "threading.py", line 870, in run
File "main1.py", line 96, in main
File "lib\site-packages\pyscreenshot\__init__.py", line 31, in grab
File "lib\site-packages\pyscreenshot\loader.py", line 145, in backend_grab
File "lib\site-packages\pyscreenshot\loader.py", line 136, in force
File "lib\site-packages\pyscreenshot\childproc.py", line 39, in childprocess_grab
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\pyscreenshotmrgm1pkk\\screenshot.png'
P.S. I am using dev version of PyInstaller, because I need TensorFlow support
Using PIL.ImageGrab.grab() instead of ps.grab() fixed problem

Python - Solving command line error for Tweepy

I am trying to use Tweepy to stream Tweets from a developer API. I want to convert this into an SQLite database file.
However, I am getting an unusual error that links to the Tweepy libraries on my computer. I am using Python 3.6.7 (if that might have something to do with it).
Please let me know if you require more information.
In Windows 10 command line:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\CONFIDENTIAL\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\CONFIDENTIAL\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\CONFIDENTIAL\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy\streaming.py", line 293, in _run
self.listener.on_exception(exception)
AttributeError: 'int' object has no attribute 'on_exception'
When initializing tweepy.Stream, you're passing an integer for the listener parameter, rather than an instance of tweepy.StreamListener. See the Streaming with Tweepy section of Tweepy's documentation.

Multithreading frozen in Python Spyder but not command prompt Windows 10

I am running a script inside Spyder that utilizes the multithreading library and the IPython console freezes with the output below. However, running the script using Windows command prompt via 'python quickstart11.py' works fine and generates the proper output.
runfile('C:/Python35/User/backtrader-master/docs/quickstart/quickstart11.py', wdir='C:/Python35/User/backtrader-master/docs/quickstart')
Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Anaconda3\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "C:\Anaconda3\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "C:\Anaconda3\lib\multiprocessing\pool.py", line 429, in _handle_results
task = get()
File "C:\Anaconda3\lib\multiprocessing\connection.py", line 251, in recv
return ForkingPickler.loads(buf.getbuffer())
AttributeError: Can't get attribute 'TestStrategy' on <module '__main__' (<_frozen_importlib_external.SourceFileLoader object at 0x000002727C461438>)>
I've tried adding freeze_support() according to Python doc, which should alleviate the problem, but it still freezes. What is going on?
Windows 10 64bit, Anaconda Python 35 64bit installer.
The problem is in Spyder. The kernel is running in interpreted mode and the addition of "freeze_support" doesn't happend before other things even if that's the intention, because the kernel is already running.
See here: https://github.com/mementum/backtrader/issues/118

USB missile launcher on Linux

I came across a page on Hacking the Kinect. It was discussing how to interface with the system. The code I used is as follows.
The script comes from Lady ada in her post on hacking the connect.
I would love get this working. I am using python
This is a link to that code
http://learn.adafruit.com/hacking-the-kinect/fuzzing
The errors I get are as follow
sudo python UsbFuzzer.py
Traceback (most recent call last):
File "UsbFuzzer.py", line 14, in <module>
dev.set_configuration()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 554, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 92, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 503, in set_configuration
_check(_lib.libusb_set_configuration(dev_handle, config_value))
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 403, in _check
raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy
The main problem here is that libusb is returning an error code, "Resource busy". This could be a permissions problem. Try running your program with sudo and see if that fixes it. This link looks promising, because it talks about how to set up a udev rule so you don't have to run as root:
pyusb: cannot set configuration
If that does not help, you could Google around for "libusb resource busy".

Categories