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

Solution 1:

TL;DR:

Problem: Long install path

Solution 1: Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package)

Solution 2: Set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1 as mentioned here.




Original answer: I got here by having this kind of error when I tried installing tensorflow library. My error was the following:

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\moj ifajlovi\faks\11master\1semestar\siap-sistemizaistrazivanjeianalizupodataka_(datamining)\projek at\rad\venvs\siap_venv\Lib\site-packages\tensorflow_estimator\python\estimator\canned\line ar_optimizer\python\utils\pycache\sharded_mutable_dense_hashtable.cpython-37.pyc'

So, there was no sharded_mutable_dense_hashtable.cpython-37.pyc file in the __pycache__ directory. But, sharded_mutable_dense_hashtable.cpython-37.pyc file was in the utils directory (which is the parent directory of __pycache__ directory).

That's why I tried manually copying the sharded_mutable_dense_hashtable.cpython-37.pyc file in the __pycache__ directory. When I tried that, I had a copy error which stated that the path was too long, so it couldn't put the file in the directory.

So, the solution:

Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package) or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1 as mentioned here.

Solution 2:

This is what I did:

I could not install my python package due to this error ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\banipreet\\anaconda3\\envs\\env-gpu\\lib\\site-packages\\requests-2.24.0.dist-info\\METADATA'

I simply removed this folder 'c:\\users\\banipreet\\anaconda3\\envs\\env-gpu\\lib\\site-packages\\requests-2.24.0.dist-info and retried pip install my-package, and it installed the package sucessfully.

Solution 3:

Remove the 260 Character Path Limit by Editing the Registry, change LongPathsEnabled to 1, the regedit path in:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

enter image description here

finally: restart your computer, or logout!

Solution 4:

First To Access The System Registry:

  1. Click Start, and then click Run.
  2. In the Open box, paste %systemroot%\syswow64\regedit , and then click OK.

Then do the following below as mentioned by Filip Savic and dayudodo:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1