user2709431
user2709431

Reputation: 51

Python not running in powershell

I am trying to follow learn python the hard way but it won't load in the powershell. I typed in the exact line that is

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")

but I know that won't work cause that isn't where python is installed. I am on a school computer so I have my python installed in mi_lemi(\filer_useres)(G:) but I tried putting that in instead and fiddling around with it but no luck either. Also my python.exe is just alled python.exe so should I remeove the '27' from it?

Thanks!

Upvotes: 0

Views: 14755

Answers (3)

Niels
Niels

Reputation: 11

I had the same problem, I finally found how to fix it.

First search python in the windows search, Python 3.7 (32-bit) or another version of python should show up. (If not first install Python.)

Then Right click on it and choose open location then you should see a folder with Python in it.

If the python in that folder is a shortcut, right click on it and choose open location again. (This step is only required if it is a shortcut.)

When you have found the real Python.exe, click on the path wich is above the files on the file manager, copy it.

Then go to Windows PowerShell and type:

[Environment]::SetEnvironmentVariable("Path", "$env:Path;INSERT WHAT YOU COPIED HERE")

In my case:

C:\Users\Stijn> [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Users\INSERT WINDOWS USERNAME\AppData\Local\Programs\Python\Python37-32")

That fixed it for me.

Upvotes: 1

uadrive
uadrive

Reputation: 1269

Just in case this is also the issue. I found Python replaced my PathExt content as well. Check your PathExt environment variable as well just in case it's been replaced with .PY.

It should look something like this.

.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY

Upvotes: 1

Keith Hill
Keith Hill

Reputation: 201592

That call will work for subsequent invocations of PowerShell but it won't help the current PowerShell session. For the current session use:

$env:Path += ";C:\Python27"
python.exe

or

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "Process")
python.exe

Or perhaps just:

C:\> c:\python27\python.exe

Upvotes: 1

Related Questions