I’m currently playing around with Python 3 on Mac OSX. One of the first issues I’ve hit is importing modules. During a Python script the import command is used to call on other modules so that their functionality can be used in the script.
However before Python can import a module, the module must be installed. This installation takes place outside of Python and within the Operating System (OS). I also ran into an issue that MacOSX Terminal did not understand the pip command. I enabled pip/resolved this by firing up a terminal and typing:
sudo python -m ensure pip –default-pip
Then to install modules type:
sudo python3 -m pip install
e.g. to install the “requests” module type:
sudo python3 -m pip install requests
Note: On Mac OSX if you type sudo python instead of sudo python3 then Mac OSX installs the module into Python 2 (which comes with Mac OSX High Sierra).