Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 3.76 KB

INSTALL.md

File metadata and controls

35 lines (31 loc) · 3.76 KB

How to Install oj command

このドキュメントの日本語バージョン

Do following steps.

  1. If you use a Windows environment, use Windows Subsystem for Linux (WSL). For beginners, Linux (especially, Ubuntu) is often easier than Windows.
    • Also, if you use Visual Studio Code (or other IDEs), close it and forget it for a while. Don't use consoles in IDEs.
    • Of course, if you were a professional, you could use oj command in the raw Windows environment.
  2. 🐍 Install Python. If you use Ubuntu (including Ubuntu in WSL), run $ sudo apt install python3.
  3. Check your Python with running $ python3 --version. If it says like Python 3.x.y, it's OK.
    • If it says something like Command 'python3' not found, you have failed to install Python.
    • If the version of Python is too old, it's not OK. The x must be greater than or equal to 6. If x is lower than 6, upgrade your Python.
  4. 📦 Install pip. If you use Ubuntu (including Ubuntu in WSL), run $ sudo apt install python3-pip.
  5. Check your pip with running $ pip3 --version. If it says something like pip x.y.z ..., it's OK.
    • If it says something like Command 'pip3' not found, you have failed to install pip.
    • Even if pip3 is not found, you may be able to use python3 -m pip instead of pip3. Try $ python3 -m pip --version. If it says pip x.y.z ..., it's OK.
    • Don't use pip or pip2. Use pip3.
  6. 🎯 Run $ pip3 install online-judge-tools to install oj command. If it says Successfully installed online-judge-tools-x.y.z (or, Requirement already satisfied: online-judge-tools), it's OK.
    • If it says Permission denied, run $ pip3 install --user online-judge-tools or $ sudo pip3 install online-judge-tools.
  7. Check oj command with $ oj --version. If it says something like online-judge-tools x.y.z, it's OK.
    • If it says something like Command 'oj' not found, you need to set PATH. Do following steps.
      1. Find the path of the oj file with running $ find / -name oj 2> /dev/null. The file is often at /home/ubuntu/.local/bin/oj or /usr/local/bin/oj.
      2. Check the found oj file is actually oj, with running $ /home/ubuntu/.local/bin/oj --version.
      3. Add the directory which contains the oj to your PATH. For example, if oj is /home/ubuntu/.local/bin/oj, write export PATH="/home/ubuntu/.local/bin:$PATH" in the end of ~/.bashrc.
        • Don't write export PATH="/home/ubuntu/.local/bin/oj:$PATH". It's not a directory.
        • If you don't use bash, write a right settings to the right file depending on your shell. For example, if you use macOS, your shell might zsh. For zsh, write the same command to ~/.zshrc.
      4. Reload the configuration with source ~/.bashrc.
        • If you don't use bash, use the appropriate way for your shell.
      5. Check your PATH with $ echo $PATH. If it says as you specified (e.g. /home/ubuntu/.local/bin:...), it's OK.
    • If it says something like ModuleNotFoundError: No module named 'onlinejudge', your Python environment is broken and you have failed to install oj command. Run $ pip3 install --force-reinstall online-judge-tools to reinstall ignoring the old one.
    • If it says something like SyntaxError: invalid syntax, you have used pip2 by mistake. Run $ pip2 uninstall online-judge-tools, and retry to install.
  8. That's all.

If you couldn't read many sentences of above instructions (e.g. if you didn't know what "run $ python3 --version" means), please ask your friends for help.