Install a Python package

To install a Python package on Macintosh

  1. Download the Python package to your workstation,
  2. Unpack the package,
  3. Open a terminal window,
  4. Start sudo,
    sudo -i
  5. Change to the directory of the package,
  6. Install the package.
    pip install PACKAGE_NAME

If you don’t install the package in sudo mode, you will get “Permission denied” errors during the package installation.

Troubleshooting

When you encounter the warning message

WARNING: The directory ‘/Users/…/Library/Caches/pip’ or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo’s -H flag.

To make yourself the owner of the /Users/…/Library/Caches/pip directory execute

sudo chown -R $(whoami) ~/Library/Caches/pip

Leave a comment

Your email address will not be published. Required fields are marked *