3

I am trying to use the lichess python API, but I cannot import it into python. I used the pip command and made sure it was updated and various other attempts, but it still gives me the error that says 'no module named 'lichess''

import lichess.api

user = lichess.api.user('thibault')
print(user['perfs']['blitz']['rating'])

command line output when I type pip install python-lichess: https://pastebin.com/1LmXJtcB

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
  • Did you do the pip install from the command line or from the python ide? Can you paste the output from when you do this: pip install python-lichess – Kieran Jul 05 '19 at 01:36
  • 1
    maybe you have two Pythons and you installed it in one Python but you run code with another Python. If you run it with `python script.py` then you can install module using the same python: `python -m pip install python-lichess` – furas Jul 05 '19 at 01:36
  • @Kieran - Here is the output, I was using the command line https://pastebin.com/1LmXJtcB – just another dev Jul 05 '19 at 01:57
  • @furas, I think I did install another python at some point, but I do not understand what I should type in the command line – just another dev Jul 05 '19 at 01:59
  • 1
    if you use `python script.py` to run your code then use `python -m pip` instead of `pip` to install module. Full command: `python -m pip install python-lichess`. This way you use the same python to install module and to run script. – furas Jul 05 '19 at 02:02
  • 1
    you can also check version for `pip` and `python`. Command: `pip -V`. Command: `python -V`. There is upper `V`. – furas Jul 05 '19 at 02:05
  • @furas, it didn't work. I am using two different pythons and I installed it on both of them, but it is still not working – just another dev Jul 05 '19 at 02:13
  • I don't have more ideas. Last one: did you save your code in file `lichess.py` and you run `python lichess.py` ? In this situation `import lichess.api` would try to import from your file `lichess.py` instead of installed module. But it could give different error message. – furas Jul 05 '19 at 02:21
  • It was named chess.py, but the problem is solved. Turns out I've been using an unstable version of python shell. But thank you very much – just another dev Jul 05 '19 at 02:29

0 Answers0