Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory – python

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.

 

Could not install packages due to an EnvironmentError [Errno 2] No such file or directory - python 1

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.

Could not install packages due to an EnvironmentError [Errno 2] No such file or directory - python 2

 

 

Step 3: In Registory Editor Click HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> FileSystem

Could not install packages due to an EnvironmentError [Errno 2] No such file or directory - python 3

 

Step 4: Right Click LongPathsEnabled and click Modify

Could not install packages due to an EnvironmentError [Errno 2] No such file or directory - python 4

 

Step 5: Set LongPathsEnabled value as 1 and click ok as shown below

Could not install packages due to an EnvironmentError [Errno 2] No such file or directory - python 5

 

 

 

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

Could not install packages due to an EnvironmentError [Errno 2] No such file or directory - python 6

 

 

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts