I expect I can run pyautogui in SSH
#t.py
import pyautogui
print(pyautogui.size())
It gave me error display;
root#server-kentang:~/py# python3 t.py
Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/Xlib/support/unix_connect.py", line 76, in get_socket
s.connect('/tmp/.X11-unix/X%d' % dno) FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "t.py", line 1, in <module>
import pyautogui
File "/usr/local/lib/python3.8/dist-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/usr/local/lib/python3.8/dist-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/usr/local/lib/python3.8/dist-packages/Xlib/protocol/display.py", line 58, in __init__
self.socket = connect.get_socket(name, host, displayno)
File "/usr/local/lib/python3.8/dist-packages/Xlib/support/connect.py", line 76, in get_socket
return mod.get_socket(dname, host, dno)
File "/usr/local/lib/python3.8/dist-packages/Xlib/support/unix_connect.py", line 78, in get_socket
raise error.DisplayConnectionError(dname, str(val))
Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 2] No such file or directory
But I already installed XRDP and its XORG and it works fine. I'm using OpenBox as Windows Manager.
Related
i get an error using d3dshot.create()
like this
Traceback (most recent call last):
File "<pyshell#7>", line 1, in
a=d3dshot.create('pil',60)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\d3dshot_init_.py", line 74, in create
pytorch_gpu_is_available=pytorch_gpu_is_available,
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\d3dshot\d3dshot.py", line 17, in call
cls._instances[cls] = super(Singleton, cls).call(*args, **kwargs)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\d3dshot\d3dshot.py", line 37, in init
self.detect_displays()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\d3dshot\d3dshot.py", line 215, in detect_displays
self.displays = Display.discover_displays()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\d3dshot\display.py", line 93, in discover_displays
dxgi_factory = d3dshot.dll.dxgi.initialize_dxgi_factory()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python37-32\lib\site-packages\d3dshot\dll\dxgi.py", line 210, in initialize_dxgi_factory
create_factory_func(IDXGIFactory1.iid, ctypes.byref(handle))
OSError: exception: access violation writing 0x4DBAF26F
I run the python code from the root. Shows an error when I just imported the module:
ERROR : Traceback (most recent call last):
File "/home/amir/photo.py", line 4, in <module>
import pyautogui as gui
File "/usr/local/lib/python3.9/dist-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/usr/local/lib/python3.9/dist-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/local/lib/python3.9/dist-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.9/dist-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/usr/local/lib/python3.9/dist-packages/Xlib/protocol/display.py", line 129, in __init__
raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":1": b'No protocol specified\n'
Im using python 3.6 and this is a module from my project -
import os
import time
from moviepy.video.io.VideoFileClip import VideoFileClip
def add_audio_to_file(original_video, dest_video):
suffix = original_video.split(".")[-1]
directory_path = os.path.dirname(dest_video)
temp_name = os.path.join(directory_path, "temp_vid_{}.{}".format(time.time(), suffix))
os.rename(dest_video, temp_name)
os.chmod(original_video, 777)
orig_videoclip = VideoFileClip(original_video)
audioclip = orig_videoclip.audio
redorded_videoclip = VideoFileClip(temp_name)
with_audio_clip = redorded_videoclip.set_audio(audioclip)
with_audio_clip.write_videofile(dest_video, progress_bar=False, threads=6, verbose=False)
os.remove(temp_name)
I get the following error:
Traceback (most recent call last):
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\MOT_Server\olympus-skeleton\core\step\step_action\utils\async_queue_reader.py", line 56, in _start_reading_from_queue
self._new_objects_in_queue_function(queue_objects)
File "C:\MOT_Server\olympus-skeleton\core\step\step_action\handler\async_handler.py", line 29, in _listener_to_handler_queue_messages_handler
messages = self._handle_function(messages)
File "C:\MOT_Server\olympus-skeleton\core\step\step.py", line 261, in process
processed_messages = handler(curr_messages)
File "C:\MOT_Server\olympus-skeleton\core\step\step.py", line 239, in _handle_message
final_messages = self._process(messages_to_process) or []
File "C:\MOT_Server\olympus-skeleton\components\steps\output_step\output_step.py", line 40, in _process
publisher.publish(messages)
File "C:\MOT_Server\olympus-skeleton\core\publisher\publisher.py", line 28, in publish
self._publish(messages)
File "C:\MOT_Server\olympus-skeleton\components\publishers\filesystem_cleaner_publisher\filesystem_cleaner_publisher.py", line 32, in _publish
files_to_delete = self._serializer.serialize(message)
File "C:\MOT_Server\olympus-skeleton\components\serializers\mot_serializers\job_completed_verifier_serializer.py", line 182, in serialize
self._add_audio_to_vid(original_video, dest_video)
File "C:\MOT_Server\olympus-skeleton\components\serializers\mot_serializers\job_completed_verifier_serializer.py", line 201, in _add_audio_to_vid
add_audio_to_file(original_video, dest_video)
File "C:\MOT_Server\olympus-skeleton\utils\recorder_utils\audio_utils.py", line 17, in add_audio_to_file
orig_videoclip = VideoFileClip(original_video)
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 91, in __init__
fps_source=fps_source)
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 33, in __init__
fps_source)
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 259, in ffmpeg_parse_infos
proc.terminate()
File "C:\Users\Borat\AppData\Local\Programs\Python\Python36\lib\site-packages\gevent\subprocess.py", line 982, in terminate
TerminateProcess(self._handle, 1)
PermissionError: [WinError 5] Access is denied
I checked the permissions and everything seems ok. In addition, i tried to change the permissions using os.chmod(original_video, 777), but still without any success.
root#raspberrypi:/home/pi/Downloads/dejavu# python2 ./example.py
######## filename: mp3/Brad-Sucks--Total-Breakdown.mp3
Failed fingerprinting
Traceback (most recent call last):
File "/home/pi/Downloads/dejavu/dejavu/__init__.py", line 79, in fingerprint_d irectory
song_name, hashes, file_hash = iterator.next()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 659, in next
raise value
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "./example.py", line 17, in <module>
song = djv.recognize(FileRecognizer, "/home/pi/Downloads/dejavu/mp3/Brad-Suc ks--Total-Breakdown.mp3")
File "/home/pi/Downloads/dejavu/dejavu/__init__.py", line 169, in recognize
return r.recognize(*options, **kwoptions)
File "/home/pi/Downloads/dejavu/dejavu/recognize.py", line 41, in recognize
return self.recognize_file(filename)
File "/home/pi/Downloads/dejavu/dejavu/recognize.py", line 29, in recognize_fi le
frames, self.Fs, file_hash = decoder.read(filename, self.dejavu.limit)
File "/home/pi/Downloads/dejavu/dejavu/decoder.py", line 51, in read
audiofile = AudioSegment.from_file(filename)
File "/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.py", line 505 , in from_file
p = subprocess.Popen(conversion_command, stdout=subprocess.PIPE, stderr=subp rocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Anybody can help me? I am a fresh man about python.
I wanna run a Python project which is proved to be correct in a Raspberry pi zero W, the system on it is a linux like Debian, I have already installed Python 2 and python 3.
when i killed the error above, another error arised like below:
root#raspberrypi:/home/pi/Downloads/dejavu# python2 example.py ######## filename: mp3/Brad-Sucks--Total-Breakdown.mp3
Fingerprinting channel 1/2 for mp3/Brad-Sucks--Total-Breakdown.mp3
Failed fingerprinting
Traceback (most recent call last):
File "/home/pi/Downloads/dejavu/dejavu/__init__.py", line 79, in fingerprint_directory
song_name, hashes, file_hash = iterator.next()
File "/usr/lib/python2.7/multiprocessing/pool.py", line 659, in next
raise value
MemoryError
Traceback (most recent call last):
File "example.py", line 17, in <module>
song = djv.recognize(FileRecognizer, "/home/pi/Downloads/dejavu/mp3/Brad-Sucks--Total-Breakdown.mp3")
File "/home/pi/Downloads/dejavu/dejavu/__init__.py", line 169, in recognize
return r.recognize(*options, **kwoptions)
File "/home/pi/Downloads/dejavu/dejavu/recognize.py", line 41, in recognize
return self.recognize_file(filename)
File "/home/pi/Downloads/dejavu/dejavu/recognize.py", line 32, in recognize_file
match = self._recognize(*frames)
File "/home/pi/Downloads/dejavu/dejavu/recognize.py", line 17, in _recognize
matches.extend(self.dejavu.find_matches(d, Fs=self.Fs))
File "/home/pi/Downloads/dejavu/dejavu/__init__.py", line 118, in find_matches
hashes = fingerprint.fingerprint(samples, Fs=Fs)
File "/home/pi/Downloads/dejavu/dejavu/fingerprint.py", line 83, in fingerprint
noverlap=int(wsize * wratio))[0]
File "/usr/lib/python2.7/dist-packages/matplotlib/mlab.py", line 1315, in specgram
mode=mode)
File "/usr/lib/python2.7/dist-packages/matplotlib/mlab.py", line 759, in _spectral_helper
result = np.conjugate(result) * result
MemoryError
Anybody meet the similary problem before ?
way to solve OSError: [Errno 2] No such file or directory
Install FFmpeg or Libav
Cause FFmpeg is almost quited by Linux, I installed Libva
sudo apt-get install libav-tools
way to solve MemoryError
Change a small mp3 file to fingerprint and recongnize
Cause the RAM of my CPU is too small to process the big file
Running python 2.7.8 on OSX 10.9
I have installed and imported pyglet, but when I run
window = pyglet.window.Window(resizable=True)
It returns
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
window = pyglet.window.Window(resizable=True)
File "/Library/Python/2.7/site-packages/pyglet/__init__.py", line 306, in __getattr__
__import__(import_name)
File "/Library/Python/2.7/site-packages/pyglet/window/__init__.py", line 1669, in <module>
from pyglet.window.carbon import CarbonPlatform, CarbonWindow
File "/Library/Python/2.7/site-packages/pyglet/window/carbon/__init__.py", line 49, in <module>
from pyglet.window import key
ImportError: cannot import name key
What would explain such an error? I have made sure that everything is running 32 bit, and checked compatibility.
Edit: full code:
import pyglet
window = pyglet.window.Window(resizable=True)
#window.event
def on_draw():
window.clear()
pyglet.gl.glColor4f(1.0,0,0,1.0)
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,
('v2i', (10, 15, 30, 35))
)
pyglet.app.run()
I fixed the previous error, I had a misnamed file... whoops...
but now I receive the error:
Traceback (most recent call last):
File "/Users/jackwoodrow/Desktop/TOK", line 3, in <module>
window = pyglet.window.Window(resizable=True)
File "/Library/Python/2.7/site-packages/pyglet/__init__.py", line 306, in __getattr__
__import__(import_name)
File "/Library/Python/2.7/site-packages/pyglet/window/__init__.py", line 1669, in <module>
from pyglet.window.carbon import CarbonPlatform, CarbonWindow
File "/Library/Python/2.7/site-packages/pyglet/window/carbon/__init__.py", line 69, in <module>
framework='/System/Library/Frameworks/QuickTime.framework')
File "/Library/Python/2.7/site-packages/pyglet/lib.py", line 90, in load_library
return self.load_framework(kwargs['framework'])
File "/Library/Python/2.7/site-packages/pyglet/lib.py", line 226, in load_framework
lib = ctypes.cdll.LoadLibrary(realpath)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/QuickTime, 6): no suitable image found. Did find:
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture