The below commands were mostly taken from this answer on StackOverflow, and assume you're running them with elevated permissions (e.g. with sudo):
apt-get install node apt-get install nodejs-legacy apt-get install npm npm -g install phantomjs pip3 install selenium
Why install nodejs-legacy? I saw this error without it.
That's it! Now you can start writing Python code.