I'm trying to use the python module Winotify
to create toast notifications, but I'm running into a problem that I can't make heads or tails out off.
The test script I'm trying to run is the following:
from winotify import Notification
toast = Notification(app_id="windows app",
title="Winotify Test Toast",
msg="New Notification!")
toast.show()
But get the following error
Traceback (most recent call last):
File "D:\01 Libraries\Documents\Tosh0kan Studios\Coding\MangaDex Feed Notifier\_toaster.pyw", line 8, in <module>
toast.show()
File "C:\Users\igor\AppData\Local\Programs\Python\Python311\Lib\site-packages\winotify\__init__.py", line 197, in show
_run_ps(command=self.script)
File "C:\Users\igor\AppData\Local\Programs\Python\Python311\Lib\site-packages\winotify\__init__.py", line 72, in _run_ps
subprocess.Popen(
File "C:\Users\igor\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\igor\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
I really have no clue what's going on, so the most I tried was uninstalling and reinstalling, installing it in an older version of Python I have (version 3.9), and it still has the same problem.
Does anyone have any idea of what's happening?
EDIT
As #Pignotto said below, Powershell wasn't on my PATH variable. Once I added it, it worked fine.
Related
I wanted to run a python script from my Java Maven project. Simple python scripts works fine without any issues.
But if i try something complicated like using OpenCV and pytesseract libraries to do some image recognition related tasks the code doesn't work.
The python script works fine if i just run it from the terminal (i have installed all the required libraries)
But the same script when called from the Java Maven project, it doesn't work.
Here is the code:
String path = "/Users/team/Desktop/my.py";
ProcessBuilder pb = new ProcessBuilder("python3","/Users/team/Desktop/my.py").inheritIO();
Process p = pb.start();
p.waitFor();
BufferedReader bfr = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = bfr.readLine()) != null) {
System.out.println(line);
}
It is throwing below error:
Traceback (most recent call last):
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 252, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/team/Desktop/my.py", line 73, in <module>
result = pytesseract.image_to_string(Image.open(src_path + "thres.png"))
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 413, in image_to_string
return {
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 416, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 284, in run_and_get_output
run_tesseract(**kwargs)
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 256, in run_tesseract
raise TesseractNotFoundError()
Could someone please help me figure this out please? I feel like the issue is because of some sort of PATH, but not sure how to fix it!
Would you mind trying using -Djava.library.path= so the java process knows where to locate the tesseract library.
I'm trying to merge video and audio files together using ffmprg but I keep on receiving this error
ERROR:
Traceback (most recent call last):
File "C:\Users\Geo\youtubedownloader\test.py", line 9, in <module>
ffmpeg.concat(video,audio, v=1 , a=1).output("C:/Users/Geo/output_video/mergedretweett.mp4/").run()
File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\site-packages\ffmpeg\_run.py", line 313, in run
process = run_async(
File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\site-packages\ffmpeg\_run.py", line 284, in run_async
return subprocess.Popen(
File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Geo\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Code:
video = ffmpeg.input("C:/Users/Geo/File.mp4")
audio = ffmpeg.input("C:/Users/Geo/File_audio.mp4")
ffmpeg.concat(video,audio, v=1 , a=1).output("C:/Users/Geo/output_video/outputvideo.mp4").run()```
The WindowsError you see does not refer to the video file but to the ffmpeg executable itself. The call to subprocess.call has no idea that File.mp4 is a filename you are passing. Windows knows that the first parameter ought to be an executable file and reports back to the interpreter that it can't find it.
Double-check that ffmpeg can be executed in the environment your interpreter is running in. You may either add it to your PATH or specify the full path to ffmpeg.exe.
I was also getting the same error.
Then I checked and found that, ffmpeg is needed.
When I installed it from this code:
conda install -c conda-forge ffmpeg
(for anaconda), my issue gets resolved.
Im trying to create a webscraper for the first time. The script wont run without a error code.
Tutorial I am using:
https://oxylabs.io/blog/python-web-scraping
I have followed all steps and have undergone further steps via other youtube tutorials but nothing has worked ;(
Error code:
Traceback (most recent call last):
File "C:\Users\hpy03\PycharmProjects\webtest\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\hpy03\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\hpy03\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/hpy03/PycharmProjects/webtest/test_scraping.py", line 5, in <module>
driver = webdriver.Chrome(executable_path='c:\path\to\windows\webdriver\executable.exe')
File "C:\Users\hpy03\PycharmProjects\webtest\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\hpy03\PycharmProjects\webtest\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'executable.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
It seems like you haven't referenced chromedriver properly. If you run chromedriver -v in Command Prompt, and get a version back, then just remove the executable_path=... from your code:
Before:
driver = webdriver.Chrome(executable_path='c:\path\to\windows\webdriver\executable.exe')
After:
driver = webdriver.Chrome()
Otherwise, you can place chromedriver.exe in the same folder as your code, and reference it like so:
driver = webdriver.Chrome(executable_path='./chromedriver.exe')
If you don't have chromedriver.exe, then see here.
I installed a library called stockfish via pip install stockfish.
So I went on and tried to setup the Stockfish via:
from stockfish import Stockfish
stockfish = Stockfish(r'C:\Users\Acer\Desktop\chess\stockfish-11-win')
That throws a WinError 5, access denied:
Exception ignored in: <function Stockfish.__del__ at 0x0429AA48>
Traceback (most recent call last):
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stockfish\models.py", line 270, in __del__
self.stockfish.kill()
AttributeError: 'Stockfish' object has no attribute 'stockfish'
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
emily = Stockfish(r'C:\Users\Acer\Desktop\chess\stockfish-11-win\src')
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stockfish\models.py", line 33, in __init__
self.stockfish = subprocess.Popen(
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Zugriff verweigert
What have I done/tried?
I tried different Stockfish Downloads, running the Idle or CMD as admin, re-installed and used different PCs, but I somehow don't get to work with Stockfish - anyone able to help me out bypassing the access denied? What do I miss when initializing? Trying Stockfish returns <class 'stockfish.models.Stockfish'> , thus it seems like it's properly imported and functioning.
I am having a simple code which has an image called "try.png" and I want to convert it from Image to Text using pytesseract but I am having some issues with the code.
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd=r'tesseract-ocr-setup-4.00.00dev.exe'
img = cv2.imread('try.png')
img= cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img))
But it's giving me an error.
Traceback (most recent call last):
File "C:/Users/user 1/PycharmProjects/JARVIS/try.py", line 6, in <module>
print(pytesseract.image_to_string(img))
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 356, in image_to_string
return {
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 359, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 270, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 241, in run_tesseract
raise e
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 238, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\user 1\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 740] The requested operation requires elevation
Process finished with exit code 1
Any idea on how to over come this error
tesseract-ocr-setup-4.00.00dev.exe sounds like a setup exe and not the tesseract itself. Check if you have actually installed tesseract and if not launch the exe to install.
For Windows download the latest version from here:
https://github.com/UB-Mannheim/tesseract/wiki
If you still get OSError: [WinError 740] The requested operation requires elevation try changing the tesseract executable to run as admin: Right Click tesseract.exe -> Properties -> Compability -> Check Run this program as an administrator -> OK .
I guess you have not installed tesseract on your system. Run tesseract-ocr-setup-4.00.00dev.exe to install it and make a note of the location where it is installed ($tesseractLocation)
If getting the same error while installing, try running it with admin access.
And Replace
pytesseract.pytesseract.tesseract_cmd=r'tesseract-ocr-setup-4.00.00dev.exe'
with
pytesseract.pytesseract.tesseract_cmd=r'$tesseractLocation'
This will resolve the issue. In the script, you have to mention the installation directory and not the setup file.
Try Uncheck "Run this program as an administrator"
TRY: Right Click tesseract.exe -> Properties -> Compability -> Uncheck Run this program as an administrator -> apply.