Do following steps.
- 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.
- 🐍 Install Python. If you use Ubuntu (including Ubuntu in WSL), run
$ sudo apt install python3
. - Check your Python with running
$ python3 --version
. If it says likePython 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 to6
. Ifx
is lower than6
, upgrade your Python.
- If it says something like
- 📦 Install pip. If you use Ubuntu (including Ubuntu in WSL), run
$ sudo apt install python3-pip
. - Check your pip with running
$ pip3 --version
. If it says something likepip 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 usepython3 -m pip
instead ofpip3
. Try$ python3 -m pip --version
. If it sayspip x.y.z ...
, it's OK. - Don't use
pip
orpip2
. Usepip3
.
- If it says something like
- 🎯 Run
$ pip3 install online-judge-tools
to installoj
command. If it saysSuccessfully 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
.
- If it says
- Check
oj
command with$ oj --version
. If it says something likeonline-judge-tools x.y.z
, it's OK.- If it says something like
Command 'oj' not found
, you need to setPATH
. Do following steps.- 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
. - Check the found
oj
file is actuallyoj
, with running$ /home/ubuntu/.local/bin/oj --version
. - Add the directory which contains the
oj
to yourPATH
. For example, ifoj
is/home/ubuntu/.local/bin/oj
, writeexport 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
.
- Don't write
- Reload the configuration with
source ~/.bashrc
.- If you don't use bash, use the appropriate way for your shell.
- Check your
PATH
with$ echo $PATH
. If it says as you specified (e.g./home/ubuntu/.local/bin:...
), it's OK.
- Find the path of the
- If it says something like
ModuleNotFoundError: No module named 'onlinejudge'
, your Python environment is broken and you have failed to installoj
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 usedpip2
by mistake. Run$ pip2 uninstall online-judge-tools
, and retry to install.
- If it says something like
- 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.