0

I bought a Lenovo laptop in November last year and it came with Windows 10 pre-installed. But I only began using it regularly 3-4 months back.

I was learning Python and I needed to install Python packages through the command prompt( I never used CMD until I decided to install the packages ). But the command prompt wouldn't recognize the command neither would it recognize the python command. I then tried some other basic commands like ipconfig which the command prompt wouldn't recognize as an external or internal command.

I checked and the command prompt has already has PATH variable set up so I don't know what the problem is. Please help. I cannot stop learning Python.

System Variables

User Variables

User Variables

User Variables

Response after I typed set command in cmd.

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\LENOVO\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-NPN80JK
ComSpec=C:\Windows\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
HOMEDRIVE=C:
HOMEPATH=\Users\LENOVO
LOCALAPPDATA=C:\Users\LENOVO\AppData\Local
LOGONSERVER=\\DESKTOP-NPN80JK
NUMBER_OF_PROCESSORS=8
OneDrive=C:\Users\LENOVO\OneDrive
OS=Windows_NT
Path=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\Desktop;C:\Python\Python37;C:\Python;C:\Users\LENOVO\Python\Python37\Scripts;C:\Users\LENOVO\Python\Python37;C:\Users\LENOVO\Python;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;;C:\\Users\\LENOVO\\python;C:\Windows\SysWow64\;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\Lib;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\DLLs;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\Lib\lib-tk;"C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\Scripts\";C:\Windows\system32;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\Desktop;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\Desktop;C:\Users\LENOVO\Python\Python37\Scripts;C:\Users\LENOVO\Python\Python37;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\Desktop;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\AppData\Local\Microsoft\WindowsApps;C:\Users\LENOVO\AppData\Local\atom\bin;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.7;C:\Users\LENOVO\Microsoft VS Code\bin;C:\Windows\System32;C:\Windows\SysWow64\;
PATHEXT=C:\Users\LENOVO\AppData\Local\Programs\Python\Python38;C:\Users\LENOVO\MyPythonScripts
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=8e0a
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
PythonPath=C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;
PY_HOME=C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\Lib;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\DLLs;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\Lib\lib-tk;
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\LENOVO\AppData\Local\Temp
TMP=C:\Users\LENOVO\AppData\Local\Temp
USERDOMAIN=DESKTOP-NPN80JK
USERDOMAIN_ROAMINGPROFILE=DESKTOP-NPN80JK
USERNAME=LENOVO
USERPROFILE=C:\Users\LENOVO
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
windir=C:\Windows

For the command

For /F Tokens^=2* %G In ('""%__AppDir__%reg.exe" Query "HKCU\Environment" /V Path"') Do @Echo ?%H?

The output is :

?C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\Desktop;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\Desktop;C:\Users\LENOVO\Python\Python37\Scripts;C:\Users\LENOVO\Python\Python37;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;C:\Users\LENOVO\Desktop;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\ProgramData\Oracle\Java\javapath;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\AppData\Local\Microsoft\WindowsApps;C:\Users\LENOVO\AppData\Local\atom\bin;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.7;C:\Users\LENOVO\Microsoft VS Code\bin;C:\Windows\System32;C:\Windows\SysWow64\;?

For the command :

For /F Tokens^=2* %G In ('""%__AppDir__%reg.exe" Query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V Path"') Do @Echo ?%H?

The output I get is :

?C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\LENOVO\Desktop;C:\Python\Python37;C:\Python;C:\Users\LENOVO\Python\Python37\Scripts;C:\Users\LENOVO\Python\Python37;C:\Users\LENOVO\Python;%PYTHONPATH%;C:\\Users\\LENOVO\\python;C:\Windows\SysWow64\;%PythonPath%;%PythonPath%\Lib;%PythonPath%\DLLs;%PythonPath%\Lib\lib-tk;"%PythonPath%;%PythonPath%\Scripts\";%SystemRoot%\system32;?
1
  • Comments are not for extended discussion; this conversation has been moved to chat. Commented Oct 2, 2020 at 1:17

3 Answers 3

1

To clarify the reason why your reported external command utilities, (ipconfig, ping, powershell, and python), do not work, it is because your %PATHEXT% variable has been overwritten by invalid data.

Your %PATHEXT% variable value content is:

C:\Users\LENOVO\AppData\Local\Programs\Python\Python38;C:\Users\LENOVO\MyPythonScripts

Whereas it should look like this:

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

To fix that please open a Command Prompt window, (cmd.exe), As administrator, copy and paste the following command into it, and press the ENTER key:

"%__AppDir__%reg.exe" Add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V PATHEXT /D "COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC" /F

In addition to that your System and User %PATH% Environment Variables are also in a very bad state. You have a great many duplicates, entries in the wrong environment, and their order is also not correct.

Based upon the entries which you provided for me, (thanks), here are my proposals to tidy them up again.

To fix your System %PATH%, open another Command Prompt window, As administrator, and copy and paste the following command into it, and press the ENTER key:

"%__AppDir__%reg.exe" Add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V Path /D "C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\ProgramData\Oracle\Java\javapath;C:\Python;C:\Python\Python37;%%PythonPath%%;C:\Windows\SysWow64\;" /F

Now you need to fix your User %PATH% Environment variable's value. To do that, open a normal Command Prompt window, (the Prompt should begin with C:\Users\LENOVO>); copy and paste the following command into it, and press the ENTER key:

"%__AppDir__%reg.exe" Add "HKCU\Environment" /V Path /D "C:\Users\LENOVO\AppData\Local\Microsoft\WindowsApps;C:\Users\LENOVO\AppData\Local\atom\bin;C:\Users\LENOVO\Microsoft VS Code\bin;C:\Users\LENOVO\Desktop;C:\Users\LENOVO\Python;C:\Users\LENOVO\Python\Python37;C:\Users\LENOVO\Python\Python37\Scripts;C:\Users\LENOVO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.8;" /F

After doing that, you should, to be sure your changes are reflected, reboot your PC.

Once rebooted, you should be able to run your commands again, and please do not add new content to any of those variables, unless you're certain of what you're doing, and what will happen as a result.

Sign up to request clarification or add additional context in comments.

Comments

0

Please make sure that the PATH environment variable includes the folder containing the executable python.exe and that each variable is delimited by a semicolon (;)

1 Comment

There is already a path for python. I added screenshots btw.
0

Wow, your %PATH% is a mess: so many references, sometimes you have five references to the same directory, ..., but I believe there is one thing you might try to solve:

Your %PATH% variable looks as follows:

... C:\Python37\Scripts;\Lib\lib-tk;"C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;;C:\Python37\Lib;C:\Python37\DLLs;C:\Python37\Lib\lib-tk;C:\Python37;C:\Python37\Scripts;\Scripts\";

                                    ^                                                                                                                                                                                          ^

Do you see it? You have an opening double quote, which is only closed far later, so all the paths inside those double quotes are not taken into account. Please look for a way to remove those double quotes and your problem should be solved.

1 Comment

Thank You for the help. I will have to search for a way do remove the double quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.