動作環境
- WSL Ubuntu 18.04
- pipenv 2020.6.2
- python 3.7.4
起きたこと
pipenv install
したときにパッケージのインストールはできるもののPipfile.lock
が更新されなくなった。
(project) user@LAPTOP:~/project$ pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Building requirements...
Resolving dependencies...
✘ Locking Failed!
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/resolver.py", line 807, in <module>
main()
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/resolver.py", line 803, in main
parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/resolver.py", line 785, in _main
resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/resolver.py", line 758, in resolve_packages
results = clean_results(results, resolver, project)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/resolver.py", line 634, in clean_results
reverse_deps = project.environment.reverse_dependencies()
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/project.py", line 374, in environment
self._environment = self.get_environment(allow_global=allow_global)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/project.py", line 364, in get_environment
environment.extend_dists(pipenv_dist)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/environment.py", line 123, in extend_dists
extras = self.resolve_dist(dist, self.base_working_set)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/environment.py", line 118, in resolve_dist
deps |= cls.resolve_dist(dist, working_set)
File "/home/user/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/environment.py", line 117, in resolve_dist
dist = working_set.find(req)
File "/home/user/project/.venv/lib/python3.7/site-packages/pkg_resources/__init__.py", line 644, in find
raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 2.0.0 (/home/user/project/.venv/lib/python3.7/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
原因と解決策
pkg_resources.VersionConflict: (importlib-metadata 2.0.0 (/home/user/project/.venv/lib/python3.7/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
importlib-metadata 2.0.0
が悪さしているらしい事がわかる。importlib-metadata<2,>=0.12
らしいので、バージョンを下げてインストールしなおせば良さそう。
ということで、今あるimportlib-metadata 2.0.0
をアンインストールして、importlib-metadata 1.7.0
をインストールしました。
(project) user@LAPTOP:~/project$ pipenv uninstall importlib-metadata
省略
(project) user@LAPTOP:~/project$ pipenv install importlib-metadata==1.7.0
Installing importlib-metadata==1.7.0…
Adding importlib-metadata to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (a65489) out of date, updating to (bc5a3a)…
Locking [dev-packages] dependencies…
Building requirements...
Resolving dependencies...
✔ Success!
Locking [packages] dependencies…
Building requirements...
Resolving dependencies...
✔ Success!
Updated Pipfile.lock (bc5a3a)!
Installing dependencies from Pipfile.lock (bc5a3a)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 —
無事解決できました。
参考記事
pip
で同じくpkg_resources.VersionConflict
が起きてしまった方がいたので、そちら方を参考にしました。
pipのVersionConflictを修正して、ライブラリインストール実行を正常に行う