pip: FileNotFoundError: [Errno 2] No such file or directory: '/home/user/anaconda3/lib/python3.6/site-packages/psutil-5.4.8.dist-info/METADATA'

Environment

  • pip version: 19.0.2
  • Python version: 3.6
  • OS: Linux Mint 19.1 (Linux 4.15.0-45-generic x86_64)
  • conda 4.6.2

Description When running Jupyter Notebook, following error prevented kernel starting:

ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'

Based on this, I tried to pip install -U jupyter_console. This failed, giving

FileNotFoundError: [Errno 2] No such file or directory: '/home/user/anaconda3/lib/python3.6/site-packages/psutil-5.4.8.dist-info/METADATA'

Upon further investigation, the reason for this is that there was as subfolder created with another psutil-5.4.8.dist-info created. Thus, by moving the files out of this nested subfolder, everything worked again.

KO: /home/user/anaconda3/lib/python3.6/site-packages/psutil-5.4.8.dist-info/psutil-5.4.8.dist-info/METADATA

OK: /home/user/anaconda3/lib/python3.6/site-packages/psutil-5.4.8.dist-info/METADATA

I wasn’t manually doing anything in these package folders; any idea what automatic process (suspect pip-related) could have caused this?

Expected behavior Directory structure should be /home/user/anaconda3/lib/python3.6/site-packages/psutil-5.4.8.dist-info/METADATA

How to Reproduce pip install -U jupyter_console

Output

Error checking for conflicts.
Traceback (most recent call last):
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2897, in _dep_map
    return self.__dep_map
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2888, in _parsed_pkg_info
    return self._pkg_info
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
    raise AttributeError(attr)
AttributeError: _pkg_info

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 503, in _warn_about_conflicts
    package_set, _dep_info = check_install_conflicts(to_install)
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_internal/operations/check.py", line 108, in check_install_conflicts
    package_set, _ = create_package_set_from_installed()
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_internal/operations/check.py", line 47, in create_package_set_from_installed
    package_set[name] = PackageDetails(dist.version, dist.requires())
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2635, in requires
    dm = self._dep_map
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2899, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2908, in _compute_dependencies
    for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2890, in _parsed_pkg_info
    metadata = self.get_metadata(self.PKG_INFO)
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1410, in get_metadata
    value = self._get(self._fn(self.egg_info, name))
  File "/home/jwfu/anaconda3/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1522, in _get
    with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/home/jwfu/anaconda3/lib/python3.6/site-packages/psutil-5.4.8.dist-info/METADATA'

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 17 (11 by maintainers)

Most upvoted comments

I solved my problem in this way: conda uninstall pip

Now pip works fine but I had to reinstall all my packages.

I solved the problem in this way.

pip install -U pip pip install psutil

conda install rsa

pip could also handle more errors from pkg_resources when trying to find distributions (or encourage pkg_resources to convert ValueError and apparently FileNotFoundError into their own type, which pip already handles - didn’t you already file a bug over there on this?).

Okay, thanks. I did file pypa/setuptools#1664. It was just to include more information in the error though, rather than asking for a specific type that pip can handle.

I started adding the extra handling to one of my PRs and was told to take it out, but haven’t gone back to it. Personally I see this as a boundary, which means handling all errors and continuing safely is okay (as an exception doesn’t indicate corrupt state in pip itself - just like OSError is generally safely continuable but an internal TypeError is not). However, I know not everyone has that POV 😃

If it was me that asked you to take it out (if I remember what you’re referring to) 😃 , it was more to limit the scope of the PR to one thing. Re: the other point, generally speaking, my own view is for pip not to try to be too “smart” by trying to fix errors. (pip already struggles simply to do what it needs to do correctly.) However, I am really in favor of providing more useful info so that exceptions can become a lot easier to diagnose, which will make it easier for people to fix issues on their own, file bug reports to pip, or file bug reports to the proper upstream.