'Installation of py3exiv2 fails on MBP M1, macOS Big Sur | InstallationError: No .egg-info directory found in

Installation of py3exiv2 (using pip) on my MacBook Pro M1 fails, with the InstallationError: No .egg-info directory found in... error.

I have tried the solutions posted in other place such as this thread, to no avail:

Installation of py3exiv2 on macOS Big Sur fails | ERROR: No .egg-info directory found in

Here is the trace from the pip log file:

2021-08-25T12:45:22,965 Exception information:
2021-08-25T12:45:22,965 Traceback (most recent call last):
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 173, in _main
2021-08-25T12:45:22,965     status = self.run(options, args)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 203, in wrapper
2021-08-25T12:45:22,965     return func(self, options, args)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 315, in run
2021-08-25T12:45:22,965     requirement_set = resolver.resolve(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 94, in resolve
2021-08-25T12:45:22,965     result = self._result = resolver.resolve(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 472, in resolve
2021-08-25T12:45:22,965     state = resolution.resolve(requirements, max_rounds=max_rounds)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 341, in resolve
2021-08-25T12:45:22,965     self._add_to_criteria(self.state.criteria, r, parent=None)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
2021-08-25T12:45:22,965     if not criterion.candidates:
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
2021-08-25T12:45:22,965     return bool(self._sequence)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 140, in __bool__
2021-08-25T12:45:22,965     return any(self)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 128, in <genexpr>
2021-08-25T12:45:22,965     return (c for c in iterator if id(c) not in self._incompatible_ids)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 32, in _iter_built
2021-08-25T12:45:22,965     candidate = func()
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 204, in _make_candidate_from_link
2021-08-25T12:45:22,965     self._link_candidate_cache[link] = LinkCandidate(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 295, in __init__
2021-08-25T12:45:22,965     super().__init__(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
2021-08-25T12:45:22,965     self.dist = self._prepare()
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 227, in _prepare
2021-08-25T12:45:22,965     dist = self._prepare_distribution()
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 305, in _prepare_distribution
2021-08-25T12:45:22,965     return self._factory.preparer.prepare_linked_requirement(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 508, in prepare_linked_requirement
2021-08-25T12:45:22,965     return self._prepare_linked_requirement(req, parallel_builds)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 570, in _prepare_linked_requirement
2021-08-25T12:45:22,965     dist = _get_prepared_distribution(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 60, in _get_prepared_distribution
2021-08-25T12:45:22,965     abstract_dist.prepare_distribution_metadata(finder, build_isolation)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/distributions/sdist.py", line 36, in prepare_distribution_metadata
2021-08-25T12:45:22,965     self.req.prepare_metadata()
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 528, in prepare_metadata
2021-08-25T12:45:22,965     self.metadata_directory = self._generate_metadata()
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 504, in _generate_metadata
2021-08-25T12:45:22,965     return generate_metadata_legacy(
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/operations/build/metadata_legacy.py", line 74, in generate_metadata
2021-08-25T12:45:22,965     return _find_egg_info(egg_info_dir)
2021-08-25T12:45:22,965   File "/opt/homebrew/lib/python3.9/site-packages/pip/_internal/operations/build/metadata_legacy.py", line 25, in _find_egg_info
2021-08-25T12:45:22,965     raise InstallationError(
2021-08-25T12:45:22,965 pip._internal.exceptions.InstallationError: No .egg-info directory found in /private/var/folders/9m/k2j6pg_95k9__bhyxsygz2540000gp/T/pip-pip-egg-info-jli5hrba```


Solution 1:[1]

Try this.

pip install --upgrade setuptools pip

Solution 2:[2]

Ok, I figured out why this does not work on M1 MacOS and how to fix it.

The problem is that M1 MacOS puts homebrew in /opt/ instead of /usr/local/. The py3exiv2 people hard coded /usr/ in setup.py. I will try to reach out to them, but am not so experienced. If you do know how to report it, please do.

Here is the full HowTo:

Install needed dependecies. At least this should be:

brew install exiv2 boost boost-python3

Download py3exiv2 from here: https://pypi.org/project/py3exiv2/#files

Extract the tar.gz into a folder. You can just doubleclick it in Finder.

Edit the setup.py and change line 25. Make sure the version number matches yours. Check the path with ls.

Old:

def get_libboost_osx():
    places = ["/usr/local/lib/"]

New:

def get_libboost_osx():
    places = ["/opt/homebrew/Cellar/boost-python3/1.78.0/lib/"]

Compress the folder content again. Your version number or foldername might be different.

tar -czvf py3exiv2-0.9.3-edited.tar.gz py3exiv2-0.9.3/* 

Then add the variables as was answered before. Note that for M1 Macs the paths are also in /opt/homebrew/ and not /usr/local/. Also make sure the version numbers match yours. I checked everything by browsing the folders with ls.

export CPLUS_INCLUDE_PATH=/opt/homebrew/Cellar/exiv2/0.27.5_1/include/:/opt/homebrew/opt/libssh/include/:/opt/homebrew/Cellar/boost/1.78.0_1/include/
export LDFLAGS="-L/opt/homebrew/Cellar/boost-python3/1.78.0/lib -L/opt/homebrew/Cellar/exiv2/0.27.5_1/lib"

Then install it. The -v gives you more hints. That is how I found the places thing in the first place. It just never found boost and it will only tell you in verbose mode.

pip3 install py3exiv2-0.9.3-edited.tar.gz -v

Hope this helped :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nesi
Solution 2 JasonTS