I am coding a chess game with the stockfish AI. However whenever i try to iport the library i get the error PermissionError: [WinError 5] Access is denied. I have searched up the error and havent found anything that has fixed my issue. I am pretty new to python so simple answers would be greatly appreciated. Here is my code:
from stockfish import Stockfish
stockfish = Stockfish(r"/users/meyer/appdata/local/programs/python/python39/lib/site-packages/stockfish")
And this is the error:
Traceback (most recent call last):
File "C:\Users\meyer\Desktop\Python\Chess\Chess ai.py", line 3, in <module>
stockfish = Stockfish(r"/users/meyer/appdata/local/programs/python/python39/lib/site-packages/stockfish")
File "C:\Users\meyer\AppData\Local\Programs\Python\Python39\lib\site-packages\stockfish\models.py", line 35, in __init__
self.stockfish = subprocess.Popen(
File "C:\Users\meyer\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\meyer\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied
Related
I am runnning the python script pywd2015.py. Everything goes fine till i create a light curve. I get the following error.
qt.xkb.compose: failed to create compose table Traceback (most recent call last): File "/home/anil/astronomylab/Wilsion devinay /src/interfaces/syntheticcurve_interface.py", line 288, in plot_selected_light_curve results = lc_io.fill_for_synthetic_light_curve().save().run().read_synthetic_light_curve() File "/home/anil/astronomylab/Wilsion devinay /src/helpers/wd_utils/wd_io.py", line 44, in run self.process = subprocess.Popen(cmd, cwd=self._cwd) File "/usr/lib/python3.10/subprocess.py", line 969, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/anil/astronomylab/Wilsion devinay /wd-precompiled/lc_source.obj
I have tried to find the solution on internet, but i am unable to get any solution. Plese help to resolve the problem! What is causing it?
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.
I am trying to open a shortcut for Notepad called Notepad.lnk.
Because I want to learn how to open applications so I can use the pygui library to manipulate them.
Got FileNotFoundError
I got this error:
Traceback (most recent call last):
File "C:\Users\{my_name}\PycharmProjects\texture-gen\main.py", line 185, in <module>
subprocess.run(['start', shortcut_path], check=True)
File "C:\Users\{my_name}\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\{my_name}\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\{my_name}\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Code
This is my python code:
if __name__ == '__main__':
import os
import subprocess
cwd = os.getcwd()
shortcut_path = os.path.join(cwd, 'Notepad.lnk')
if not os.path.exists(shortcut_path):
print('Error: "Notepad.lnk" shortcut not found')
subprocess.run(['start', shortcut_path], check=True)
Debugging
I have checked the name of the shortcut is Notepad.lnk and is in the current working directory.
Why is this not working?
I know this has been answered but nothing works, I run my code
import pytesseract
import cv2
pytesseract.pytesseract.tesseract_cmd = r"C:\\Users\\aidan\\AppData\\Local\\Tesseract-OCR"
image = cv2.imread(r'C:\Users\aidan\OneDrive\Desktop\download.jpg')
cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(image))
cv2.imshow('Result',image)
cv2.waitKey()
and I always get this error
[ WARN:0#0.043] global D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('download.jpg'): can't open/read file: check file path/integrity
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied
how can I fix this?
You have dropped the executable in the cmd-variable:
pytesseract.pytesseract.tesseract_cmd = r"C:\Users\aidan\AppData\Local\Tesseract-OCR\tesseract.exe"
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.