Pip cannot find metadata file - EnvironmentError

I meet the same problem

ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/root/anaconda3/lib/python3.6/site-packages/tornado-6.0.4.dist-info/METADATA

then I cd /root/anaconda3/lib/python3.6/site-packages/tornado-6.0.4.dist-info/ && ls

DESCRIPTION.rst  LICENSE.txt  metadata.json

finally, I did cp metadata.json METADATA solved the problem. maybe this is helpful to you.


I think the root of your error is that your pip is configured to work with Python3.5 (and looks in its specific Pythonpath for the metadata), while your Python version is 3.6.8

Virtual environments in Python 3 have been made simpler, in my opinion, with the usage of the built-in venv. Also, your Python and Flask versions should coincide, which is here, not the case.

I'd suggest you take the following steps

  • Create a new virtual environment using

python3 -m venv /path/to/new/virtual/environment

  • Activate the virtual environment by
cd /path/to/new/virtual/environment
source env/bin/activate

You now have an isolated, clean-slate environment, where you only have a single version of Python.

  • Run pip install --upgrade pip to upgrade the virtual environment pip to the version that is compatible with your Python version.

  • Run pip install flask, and install your whole stack from scratch, so that the libraries and Python executable versions are aligned.


I just ran into this with a different package, using Python 3.6.5 and pip 19.2.3. I was hesitant to use the solutions here (and on similar SO questions) so I just tried the following and it cleared up the issue:

pip install --force-reinstall package_with_metadata_issue

Note that my case was complaining about the black package, which was a dependency of something else I was trying to install (with a simple pip install other_package). Black had already been installed and working on my system for a while, so it's unclear how it got into a bad state or what changed in pip such that it couldn't handle the package's state.

To be specific, the OP could try:

pip install --force-reinstall virtualenv

Though it seems like many other people here had an issue with pip itself, so that may just be kicking the can down the road until pip is in a good state.


I encountered the same problem recently.

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '~/.local/lib/python3.7/site-packages/pip-19.0.1.dist-info/METADATA'

In the folder

~/.local/lib/python3.7/site-packages/pip-19.0.1.dist-info/

I found another one named pip-19.0.1.dist-info, and the last one contained all the required files for the pip.

I just used

cd ~/.local/lib/python3.7/site-packages/pip-19.0.1.dist-info/
cp -r ./pip-19.0.1.dist-info/* ./
rm -r ./pip-19.0.1.dist-info

Obviously that you need to replace python version with your own and also check if files

entry_points.txt  INSTALLER  LICENSE.txt  METADATA  RECORD  top_level.txt  WHEEL

are in here.

Maybe it will help you, luck.