In python we have one of the common errors which is like could not install packages due to an EnvironmentError: [Errno 2] No such file or directory or could not install packages due to an OSError: [Errno 2] No such file or directory as shown below.
We can use two methods as a solution to this error.
- Solution 1: SET LongPathsEnabled to 1
- Solution 2: Roundabout Solution of Reinstalling python:
Solutions for the Error: Could not install packages due to an EnvironmentError / Could not install packages due to an OSError
Solution 1: SET LongPathsEnabled to 1
Step 1: Open Windows Run by pressing Windows Button + R
Step 2: Enter value as regedit – “regedit” command in the Run box is a quick way to get registry editor.
Step 3: In Registory Editor Click HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> FileSystem
Step 4: Right Click LongPathsEnabled and click Modify
Step 5: Set LongPathsEnabled value as 1 and click ok as shown below
Solution 2: Roundabout Solution of Reinstalling python:
Second solution is to Uninstall python then Reinstall it again after, successful reinstallation, you HAVE TO DISABLE THE PATH LENGTH LIMIT