# Troubleshooting

Links to common errors when running PoPy models are shown in Table 77:-

Table 77 Solutions to common PoPy issues
Problem | Solution
--- | ---
‘popy_run’ is not recognized | run popy_env before popy_run
The term ‘popy_run’ is not recognized as the name of a cmdlet | run popy_env before popy_run
‘popy_env’ is not recognized | put ‘popy_env.bat’ on system path
The term ‘popy_env’ is not recognized as the name of a cmdlet | put ‘popy_env.bat’ on system path
‘popy_env’ permission error | use dos prompt to call popy_env

## ‘popy_run’ is not recognized

### Scenario

You get this error if you open a dos prompt and attempt to run the popy_run program as follows:-

    $ popy_run

Then get the response:-

    'popy_run' is not recognized as an internal or external command,
    operable program or batch file.

### Cause

The problem is that the PoPy environment has not been enabled, so Microsoft Windows does not know where to look for the command ‘popy_run’.

### Solution

The solution is to run popy_env before you do popy_run, as follows:-

    $ popy_env
    $ popy_run

popy_run should now work as expected.

## The term ‘popy_run’ is not recognized as the name of a cmdlet

### Scenario

You get this error if you open a powershell prompt and attempt to run the popy_run program as follows:-

    $ popy_run

Then get the response:-

    popy_run : The term 'popy_run' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + popy_run
    + ~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (popy_run:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

Usually in difficult to read red on blue writing.

### Cause

The problem is that the PoPy environment has not been enabled, so Microsoft Windows does not know where to look for the command ‘popy_run’.

### Solution

The solution is to run popy_env before you do popy_run, as follows:-

    $ popy_env
    $ popy_run

popy_run should now work as expected.

## ‘popy_env’ is not recognized

### Scenario

You start a dos prompt and type the following command:-

    $ popy_env

Then you see the message:-

    'popy_env' is not recognized as an internal or external command,
    operable program or batch file.

### Cause

PoPy is either not installed or your system path is not configured correctly.

### Solution

In a dos prompt type:-

    $ echo %PATH%

In order for PoPy to work the directory containing ‘popy_env.bat’ on your machine, needs to be listed in the Microsoft Windows system path. If the ‘popy_env.bat’ directory is not present, then you need to manually add it. In a dos prompt you can do this:-

    $ set PATH=%PATH%;c:\PoPy

Where ‘c:\PoPy’ is the recommended install directory for PoPy.

To save the path permanently do:-

    $ setx PATH %PATH%

Note you probably need admin rights to use the ‘setx’ command. Once your Microsoft Windows path is sorted out you should be able to run and test the PoPy environment as follows:-

    $ popy_env
    $ popy_info

## The term ‘popy_env’ is not recognized as the name of a cmdlet

### Scenario

You start a powershell prompt and type the following command:-

    $ popy_env

Then you see the message:-

    popy_env : The term 'popy_env' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + popy_run
    + ~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (popy_run:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

### Cause

PoPy is either not installed or your system path is not configured correctly.

### Solution

In a powershell prompt type:-

    $ $env:Path

In order for PoPy to work the directory containing ‘popy_env.bat’ on your machine, needs to be listed in the Microsoft Windows system path. If the ‘popy_env.bat’ directory is not present, then you need to manually add it. In a powershell prompt prompt you can do this:-

    $ $env:Path = "$env:Path;c:\PoPy"

Where ‘c:\PoPy’ is the recommended install directory for PoPy.

To save the new path permanently do:-

    $ setx PATH $env:Path

Note you probably need admin rights to use the ‘setx’ command. Once your Microsoft Windows path is sorted out you should be able to run and test the PoPy environment as follows:-

    $ popy_env
    $ popy_info

## ‘popy_env’ permission error

### Scenario

You start a powershell prompt and type the following command:-

    $ popy_env

Then you see the message:-

    popy_env : File C:\PoPy\popy_env.ps1 cannot be loaded because running scripts is disabled on
    this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:1
    + popy_env
    + ~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess

### Cause

You do not have sufficient Powershell script execution rights to run the popy_env setup script.

### Solution1

If you are an Administrator on your Microsoft Windows system, you may grant execution rights to all powershell scripts, by opening a Administrator powershell prompt and running this command:-

    $ set-ExecutionPolicy unrestricted

Or possibly just set the execution policy for the popy_env script alone:-

    $ set-ExecutionPolicy ByPass -File c:\PoPy\popy_env.ps1

This should then allow you to run:-

    $ popy_env

From a normal non-admin powershell prompt.

For more information on the Powershell script permission system see this page:-

https://docs.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_execution_policies

### Solution2

An alternative solution maybe to Uninstall PoPy and reinstall PoPy in a location where your Microsoft Windows user has more permissions. It’s a good idea to avoid folders like:-

    c:\Program Files\PoPy

We recommend this directory, if you want non-admin users to run PoPy:-

    c:\PoPy

For more information see Install PoPy

### Solution3

You could invoke popy_env from a dos prompt instead and just not use Powershell. For example start PoPy using Desktop Shortcut Method.