Answers.Body: <p>If you've already installed python-chess via pip/conda/choco or your favourite package manager, then to use chess.pgn, in your .py files just call <code>from chess import pgn</code> or <code>import chess.pgn</code>. You have to explicitly write either import, even if you already have <code>import chess</code>.</p>
  
  <p>Then you can use it like</p>
  
  <pre><code>from chess import pgn
  
  with open("my_pgn_file.pgn", "r") as pf:
      game = pgn.read_game(pf)
  </code></pre>
  
  <p>If I had used <code>import chess.pgn</code> instead, then I call it by changing the last line to <code>game = chess.pgn.read_game(pf)</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-17T09:43:06.493Z
Answers.LastActivityDate: 2020-01-17T09:43:06.493Z
Answers.UserDisplayName: Remellion
Answers.Body: <p>First you need to install this library:</p>
  
  <pre><code>pip install python-chess
  </code></pre>
  
  <p>And make sure you're using the right <code>pip</code>, because still in some Linus distros <code>pip</code> and <code>python</code> are <code>python 2.x</code> and for <code>python 3.x</code> you should use <code>pip3</code> and <code>python3</code>. If you want to check try this:</p>
  
  <pre><code>pip --version
  </code></pre>
  
  <p>You will see an output like this that will tell you what python you're using, in my case it's 3.8:</p>
  
  <blockquote>
    <p>pip 19.2.3 from /usr/lib/python3.8/site-packages/pip (python 3.8)</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-16T21:33:07.240Z
Answers.LastActivityDate: 2020-01-17T09:34:23.680Z
Answers.LastEditDate: 2020-01-17T09:34:23.680Z
Answers.UserDisplayName: SMMousaviSP
Body: <p>I don't know how to import chess.pgn on Python.
  I searched everywhere, but I didn't find anything. Can anybody here help me? </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-16T19:57:26.380Z
Comments.Text: I guess you want `chess.pgn` from the python-chess library (?). The installation is covered in the [documentation](https://pypi.org/project/python-chess/#installing).
Comments.UserDisplayName: Ellie
Tags: <software><pgn><python>
Title: How to install chess.pgn on python?
ThreadText: # How to install chess.pgn on python?
  
  (Asked by: username_0 on 2020-01-16)
  
  I don't know how to import chess.pgn on Python.
  I searched everywhere, but I didn't find anything. Can anybody here help me?
  
  **Tags:** software, pgn, python
  
  > **Comments:**
  > **username_1**: I guess you want `chess.pgn` from the python-chess library (?). The installation is covered in the [documentation](https://pypi.org/project/python-chess/#installing).  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-01-17. Score: 2 | Accepted answer
  
  If you've already installed python-chess via pip/conda/choco or your favourite package manager, then to use chess.pgn, in your .py files just call `from chess import pgn` or `import chess.pgn`. You have to explicitly write either import, even if you already have `import chess`.
  
  Then you can use it like
  
  ```
  from chess import pgn
  
  with open("my_pgn_file.pgn", "r") as pf:
      game = pgn.read_game(pf)
  
  ```
  
  If I had used `import chess.pgn` instead, then I call it by changing the last line to `game = chess.pgn.read_game(pf)`.
  
  
  ---
  
  ### Answer by username_3 on 2020-01-16. Score: 4
  
  First you need to install this library:
  
  ```
  pip install python-chess
  
  ```
  
  And make sure you're using the right `pip`, because still in some Linus distros `pip` and `python` are `python 2.x` and for `python 3.x` you should use `pip3` and `python3`. If you want to check try this:
  
  ```
  pip --version
  
  ```
  
  You will see an output like this that will tell you what python you're using, in my case it's 3.8:
  
  > pip 19.2.3 from /usr/lib/python3.8/site-packages/pip (python 3.8)
  
  
  ---
  
  