user3848207
user3848207

Reputation: 4967

How to fix `The system cannot find the path specified` error on Windows 10?

I am using Windows 10.

I keep encountering the error message The system cannot find the path specified whenever I run a python script, start a cygwin terminal, bash script ...

There is no meaningful error message to pinpoint the exact cause. I suspect this is due to one of the pathnames in PATH variable to be pointing to non-existent path. How can I find out which pathname is causing it?

Upvotes: 13

Views: 35851

Answers (3)

user22809845
user22809845

Reputation: 1

You should also try and change around the order of the command. Put the -out attribute at the end of the command.

Upvotes: 0

factorypolaris
factorypolaris

Reputation: 2857

Powershell Path Test

Here is a one line Powershell script that will test all paths in your PATH Environment Variable exist. It will report OK or MISSING for each path. If any paths are listed as missing, you should manually remove them from the Environment Variable.

@($env:path -split ";").ForEach({ if($_) {$result = 'MISSING |';if(Test-Path -path $_) { $result = '     OK |'};-join($result, ' ', $_); }})

Option 2

Run the following from an Elevated CMD prompt. This ensures all windows paths and executables are available, permissions correct and non corrupt. After running it, it will give further instructions if needed.

sfc /scannow

About sfc /scannow


Option 3

Open the Registry Editor (regedit.exe). Check the following (if the exist) for invalid not wanted paths. As Usual, BACKUP Registry Before Making Changes.

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

Option 4

Get the small utility Process Monitor from Microsoft's site. Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. You WILL find the offending path using this tool.

  1. Download, Extract & Run
  2. Close as many open programs as possible.
  3. In Process Monitor, under file is a capture events checkbox to enable/disable. Once you get it open, stop capturing, then choose Edit -> Clear Display.
  4. Now get ready to reproduce the "System cannot find the path specified" error.
  5. Just before triggering the error, enable "Capture Events". Upon the error, immediately disable "Capture Events" in Process Monitor.
  6. Use the "Filter" menu to find the offending operation. Find rows with a Result of "NAME NOT FOUND" or "PATH NOT FOUND". The offender will likely have an "Event Class" = "File System" || "Registry". It may be another Result/Event Class but, I would start there.

Some Filters to try and narrow down the offender:

  • "Result" -> NOT -> "SUCCESS"
  • "Process Name" -> IS -> "cmd.exe" (or other shell)

After you find what you're looking for, and fix the issue, you will at minimum need to close and re-open your prompt before re-testing, but may also need to perform a reboot.

If removal of the offending record can be uninstalled vs just removed, do this as a bad/outdated Filesystem path may only be half the issue, additionally requiring a registry record update. The uninstaller should solve both.

If changes to to your Registry are needed, Ensure you first create a backup using regedit.exe.

Upvotes: 27

Ankit Arora
Ankit Arora

Reputation: 34

See there is a simple way to do this just follow this link to find your PATH variables in Advanced setting

https://docs.oracle.com/en/database/oracle/r-enterprise/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0

Now it is highly unlikely that you will be having more than a handful PATH variables so I recommend checking each of theses PATH variable and whichever is faulty just remove it

Or, just add a new PATH variable with the path to your python library files

Upvotes: 0

Related Questions