Python35-32
is installed on my PC running Windows 7 64-bit, in the directory ‘C:/Program Files (x86)/Python35-32’.
My Python scripts are installed in:
C:/Program Files (x86)/Python35-32/Scripts/pyscripts
The System Environment Variable ‘Path’ includes:
C:/Program Files (x86)/Python35-32’
and:
C:/Program Files (x86)/Python35-32/Scripts/pyscripts
The System Variable ‘PATHEXT ‘ is:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY
The User Environment Variable ‘PATH’ is:
C:/Program Files (x86)/Python35-32;C:/Program Files (x86)/Python35-32/Scripts/pyscripts
The Python current working directory is;
C:/Program Files (x86)/Python35-32
There are several scripts in the directory ‘pyscripts’: ‘CleanupStops.py’ and ‘concord.py’ are two of them.
Upon entering the following at the Python prompt:
>>> CleanupStops.py`
The following error message is returned;
Traceback (most recent call last):
File “<stdin>”, line 1, in < module.
NameError: name ‘CleanupStops’ is not defined
Invoking another script results in the same error message.
I can run the scripts from PowerShell if I change the current working directory to C:/Program Files (x86)/Python35-32/Scripts/pyscripts
.
I have researched similar issues which were resolved by:
- Inserting the correct path into the environment variables
- Including the file extension
.py
and/or - Changing the current working directory to where the scripts are located.
I have incorporated these, but still receive a NameError
as described above.
I would also like to run python scripts from PowerShell without having to change the current working directory every time I open PowerShell. I have not found advice on how to do this. How do I resolve these problems?