anthonydb/practical-sql

Installation Instructions for PL/Python Extension

anthonydb opened this issue · 0 comments

Over time, various distributions of PostgreSQL have modified the steps for installing PL/Python support. This issue will track updates (which are reflected in the 2nd Edition of Practical SQL).

macOS

If you are using Postgres.app as described in the book, please see its PL/Python support documentation.

Windows 10 and 11

First, make sure you have installed the EDB Language Pack as part of your PostgreSQL installation.

Then follow these steps:

  1. Open the Windows Control Panel by clicking the Search icon on the Windows taskbar, entering Control Panel, and then clicking the Control Panel icon.

  2. In the Control Panel app, enter Environment in the search box. In the list of search results displayed, click Edit the System Environment Variables. A System Properties dialog will appear.

  3. In the System Properties dialog, on the Advanced tab, click Environment Variables. The dialog that opens has two sections: User variables and System variables. In the System variables section, if you don’t see a PATH variable, continue to step a to create a new one. If you do see an existing PATH variable, continue to step b to modify it.

    a. If you don’t see PATH in the System variables section, click New to open a New System Variable dialog.
    In the Variable name box, enter PATH. In the Variable value box, enter C:\edb\languagepack\v2\Python-3.9. (Instead of typing, you can click Browse Directory and navigate to the directory in the Browse For Folder dialog.) When you’ve either entered the path manually or browsed to it, click OK on the dialog to close it.

    b. If you do see an existing PATH variable in the System variables section, highlight it and click Edit. In the list of variables that displays, click New and enter C:\edb\languagepack\v2\Python-3.9. Once you’ve added the Language Pack path, highlight it in the list of variables and click Move Up until the path is at the top of the variables list. That way, PostgreSQL will find the correct Python version if you have additional Python installations.

  4. Finally, in the System variables section, click New. In the New System Variable dialog, enter PYTHONHOME in the Variable name box. In the Variable value box, enter C:\edb\languagepack\v2\Python-3.9.

When you’re finished, click OK in all dialogs to close them. Note that these Python path settings will take effect the next time you restart your system.