Answers.Body: <p>The argument needs to point to the Stockfish executable. If you download the <a href="https://stockfishchess.org/files/stockfish-11-win.zip" rel="nofollow noreferrer">v11 zip from the Stockfish website</a>, extract it and find the directories with the executables.</p>
  <p>I extracted it to <code>C:\Users\&lt;username&gt;\Downloads\stockfish-11-win</code></p>
  <p>The executables are in <code>C:\Users\&lt;username&gt;\Downloads\stockfish-11-win\Windows</code></p>
  <p><a href="https://i.sstatic.net/2zBY5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2zBY5.png" alt="Stockfish executables" /></a></p>
  <p>To use the executable, give the path <em>to the executable</em> like so:</p>
  <pre><code>from stockfish import Stockfish
  
  stockfish = Stockfish(r'C:\Users\&lt;username&gt;\Downloads\stockfish-11-win\Windows\stockfish_20011801_x64.exe')
  </code></pre>
  <p>The default value for the path you give is <code>&quot;stockfish&quot;</code>, so if you add your directory with the executables to the path, and rename the exe you want to <code>stockfish</code>, you should be able to do:</p>
  <pre><code>from stockfish import Stockfish
  
  stockfish = Stockfish()
  </code></pre>
  <p>Re. your comment:</p>
  <blockquote>
  <p>no other stockfish related &quot;commands&quot; will work: <code>OSError: [Errno 22] Invalid argument</code>  ... so it seemingly fixed a problem but the next instantly occured.</p>
  </blockquote>
  <p>The ArgumentError is presumably because you're passing a wrong argument. For example, I ran the commands in the <a href="https://github.com/zhelyabuzhsky/stockfish/blob/master/README.md" rel="nofollow noreferrer">readme in the github repository</a> and it works perfectly fine.</p>
  <p><a href="https://i.sstatic.net/BtIJr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BtIJr.png" alt="Demo" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T18:08:08.290Z
Answers.Text: First off, thanks for the help! I tried your suggested solution and at least it doesn't throw up the earlier error, though it opens the .exe file (upon executing the .py file) and no other stockfish related "commands" will work: `OSError: [Errno 22] Invalid argument
  ` ... so it seemingly fixed a problem but the next instantly occured. @Pranav Hosangadi
Answers.UserDisplayName: velotoy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T18:16:03.970Z
Answers.Text: @velotoy, see if my edit helps. Make sure the arguments you pass are in the format it expects.
Answers.UserDisplayName: pho
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T18:17:59.990Z
Answers.Text: I ran it the script (initializing the stockfish directory) and an external .cmd popup appeared. Upon closing it (as mentioned) no arguments, e.g. set_position, .get_board_visual, etc. worked.
Answers.UserDisplayName: velotoy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T18:35:41.523Z
Answers.Text: I think the external cmd popup is the underlying stockfish process (although I don't see _why_ it would open it as a popup instead of a subprocess). It should work if you don't close it. I don't see any external popup on my computer when running in either a command prompt or in Spyder.
Answers.UserDisplayName: pho
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T19:02:53.703Z
Answers.Text: Okay thanks! Yeah, I'm running it in the standard idle, but I suppose it's fine. Marked as working!
Answers.UserDisplayName: velotoy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-12T11:53:54.220Z
Answers.Text: Go to: 'https://stockfishchess.org/files/' to see the full list of available executables (and more recent versions)
Answers.UserDisplayName: elPastor
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T16:45:44.787Z
Answers.LastActivityDate: 2020-08-28T18:14:21.973Z
Answers.LastEditDate: 2020-08-28T18:14:21.973Z
Answers.UserDisplayName: pho
Body: <p>I know this isn't a programming forum, though it's chess-related, hence the placement on here. Basically, I'm trying to setup stockfish with Python on my PC. I installed it via <code>pip install stockfish</code>.</p>
  <p>So I went on and tried to setup the Stockfish via:</p>
  <pre><code>from stockfish import Stockfish
  
  stockfish = Stockfish(r'C:\Users\Acer\Desktop\chess\stockfish-11-win')
  </code></pre>
  <p>That throws a WinError 5, access denied:</p>
  <pre><code>Exception ignored in: &lt;function Stockfish.__del__ at 0x0429AA48&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stockfish\models.py&quot;, line 270, in __del__
      self.stockfish.kill()
  AttributeError: 'Stockfish' object has no attribute 'stockfish'
  Traceback (most recent call last):
    File &quot;&lt;pyshell#4&gt;&quot;, line 1, in &lt;module&gt;
      emily = Stockfish(r'C:\Users\Acer\Desktop\chess\stockfish-11-win\src')
    File &quot;C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\stockfish\models.py&quot;, line 33, in __init__
      self.stockfish = subprocess.Popen(
    File &quot;C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py&quot;, line 854, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File &quot;C:\Users\Acer\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py&quot;, line 1307, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  PermissionError: [WinError 5] Zugriff verweigert
  </code></pre>
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-28T16:18:12.657Z
Comments.Text: I'm not sure about this, but I think you need to have the Stockfish engine already installed and `r'C:\Users\Acer\Desktop\chess\stockfish-11-win'` is the path to the binary. `pip install stockfish`  just allows you to easily call the engine from your Python code.
Comments.UserDisplayName: pho
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-28T16:35:54.983Z
Comments.Text: Yeah right, I installed the 11th version for Windows and have it in the directory you mentioned. (Just the unzipped downloaded file), did I miss something?
Comments.UserDisplayName: velotoy
Tags: <stockfish><python>
Title: Unable to run Stockfish on Python
ThreadText: # Unable to run Stockfish on Python
  
  (Asked by: username_0 on 2020-08-28)
  
  I know this isn't a programming forum, though it's chess-related, hence the placement on here. Basically, I'm trying to setup stockfish with Python on my PC. I installed it 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: 
  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 "", line 1, in 
      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
  
  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?
  
  **Tags:** stockfish, python
  
  > **Comments:**
  > **username_1**: I'm not sure about this, but I think you need to have the Stockfish engine already installed and `r'C:\Users\Acer\Desktop\chess\stockfish-11-win'` is the path to the binary. `pip install stockfish`  just allows you to easily call the engine from your Python code.  
  > **username_0**: Yeah right, I installed the 11th version for Windows and have it in the directory you mentioned. (Just the unzipped downloaded file), did I miss something?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-08-28. Score: 5 | Accepted answer
  
  The argument needs to point to the Stockfish executable. If you download the v11 zip from the Stockfish website, extract it and find the directories with the executables.
  I extracted it to C:\Users\\Downloads\stockfish-11-win
  The executables are in C:\Users\\Downloads\stockfish-11-win\Windows
  
  To use the executable, give the path to the executable like so:
  from stockfish import Stockfish
  
  stockfish = Stockfish(r'C:\Users\\Downloads\stockfish-11-win\Windows\stockfish_20011801_x64.exe')
  
  The default value for the path you give is "stockfish", so if you add your directory with the executables to the path, and rename the exe you want to stockfish, you should be able to do:
  from stockfish import Stockfish
  
  stockfish = Stockfish()
  
  Re. your comment:
  
  no other stockfish related "commands" will work: OSError: [Errno 22] Invalid argument  ... so it seemingly fixed a problem but the next instantly occured.
  
  The ArgumentError is presumably because you're passing a wrong argument. For example, I ran the commands in the readme in the github repository and it works perfectly fine.
  
  > **Comments:**
  > **username_0**: First off, thanks for the help! I tried your suggested solution and at least it doesn't throw up the earlier error, though it opens the .exe file (upon executing the .py file) and no other stockfish related "commands" will work: `OSError: [Errno 22] Invalid argument ` ... so it seemingly fixed a problem but the next instantly occured. @Pranav Hosangadi  
  > **username_1**: @username_0, see if my edit helps. Make sure the arguments you pass are in the format it expects.  
  > **username_0**: I ran it the script (initializing the stockfish directory) and an external .cmd popup appeared. Upon closing it (as mentioned) no arguments, e.g. set_position, .get_board_visual, etc. worked.  
  > **username_1**: I think the external cmd popup is the underlying stockfish process (although I don't see _why_ it would open it as a popup instead of a subprocess). It should work if you don't close it. I don't see any external popup on my computer when running in either a command prompt or in Spyder.  
  > **username_0**: Okay thanks! Yeah, I'm running it in the standard idle, but I suppose it's fine. Marked as working!  
  > **username_2**: Go to: 'https://stockfishchess.org/files/' to see the full list of available executables (and more recent versions)  
  
  ---
  
  