To work with PortalPy from your local PC, you'll have to install the module. To do so, complete the following steps:
- On your PC, create a directory called portalpy (mine is C:\Projects\portalpy).
- Go to the Esri GitHub portalpy repository and download PortalPy. Unzip the archive so portalpy.py sits at the root of the portalpy directory you just created on your local PC.
- On your PC, create an environmental variable with a variable name of PYTHONPATH whose variable value of the full path to your portalpy folder; in my case, C:\Projects\portalpy.
- Create a file called test.py in the same directory as portalpy.py, and then enter the following code snippet into test.py:
import portalpy url = "https://portal_url.com/portal_web_adaptor_name" ...