如何修复 pipelinev 中的 VersionConflict 锁定失败?

pipenv我在 docker 容器内使用。我尝试安装一个包,发现安装成功(添加到 Pipfile 中),但锁定一直失败。直到昨天一切都很好。这是错误:


(app) root@7284b7892266:/usr/src/app# pipenv install scrapy-djangoitem

Installing scrapy-djangoitem…

Adding scrapy-djangoitem to Pipfile's [packages]…

✔ Installation Succeeded 

Pipfile.lock (6d808e) out of date, updating to (27ac89)…

Locking [dev-packages] dependencies…

Building requirements...

Resolving dependencies...

✘ Locking Failed! 

Traceback (most recent call last):

  File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 807, in <module>

    main()

  File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 803, in main

    parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)

  File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 785, in _main

    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)

  File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 758, in resolve_packages

    results = clean_results(results, resolver, project)

  File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 634, in clean_results

    reverse_deps = project.environment.reverse_dependencies()

  File "/usr/local/lib/python3.7/site-packages/pipenv/project.py", line 376, in environment

    self._environment = self.get_environment(allow_global=allow_global)

  File "/usr/local/lib/python3.7/site-packages/pipenv/project.py", line 366, in get_environment

    environment.extend_dists(pipenv_dist)

  File "/usr/local/lib/python3.7/site-packages/pipenv/environment.py", line 127, in extend_dists

    extras = self.resolve_dist(dist, self.base_working_set)


可能出什么问题了?


不负相思意
浏览 136回答 5
5回答

慕容3067478

这是我的调试笔记。仍然不确定哪个包导致了问题,但这似乎确实解决了问题。pipenv install首次使用 pipelinev version运行时出现的错误2020.8.13。Traceback (most recent call last):&nbsp; File "/usr/local/bin/pipenv", line 8, in <module>&nbsp; &nbsp; sys.exit(cli())&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 829, in __call__&nbsp; &nbsp; return self.main(*args, **kwargs)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 782, in main&nbsp; &nbsp; rv = self.invoke(ctx)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke&nbsp; &nbsp; return _process_result(sub_ctx.command.invoke(sub_ctx))&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke&nbsp; &nbsp; return ctx.invoke(self.callback, **ctx.params)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke&nbsp; &nbsp; return callback(*args, **kwargs)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func&nbsp; &nbsp; return ctx.invoke(f, obj, *args, **kwargs)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke&nbsp; &nbsp; return callback(*args, **kwargs)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func&nbsp; &nbsp; return f(get_current_context(), *args, **kwargs)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 252, in install&nbsp; &nbsp; site_packages=state.site_packages&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1928, in do_install&nbsp; &nbsp; site_packages=site_packages,&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 580, in ensure_project&nbsp; &nbsp; pypi_mirror=pypi_mirror,&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 512, in ensure_virtualenv&nbsp; &nbsp; python=python, site_packages=site_packages, pypi_mirror=pypi_mirror&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 999, in do_create_virtualenv&nbsp; &nbsp; project._environment.add_dist("pipenv")&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 135, in add_dist&nbsp; &nbsp; self.extend_dists(dist)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 127, in extend_dists&nbsp; &nbsp; extras = self.resolve_dist(dist, self.base_working_set)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 122, in resolve_dist&nbsp; &nbsp; deps |= cls.resolve_dist(dist, working_set)&nbsp; File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 121, in resolve_dist&nbsp; &nbsp; dist = working_set.find(req)&nbsp; File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 642, in find&nbsp; &nbsp; raise VersionConflict(dist, req)pkg_resources.VersionConflict: (importlib-metadata 2.0.0 (/usr/local/lib/python3.6/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))如果你运行pip install -U pipenv它似乎会更改importlib-metadata版本:Installing collected packages: importlib-metadata&nbsp; Attempting uninstall: importlib-metadata&nbsp; &nbsp; Found existing installation: importlib-metadata 2.0.0&nbsp; &nbsp; Uninstalling importlib-metadata-2.0.0:&nbsp; &nbsp; &nbsp; Successfully uninstalled importlib-metadata-2.0.0Successfully installed importlib-metadata-1.7.0现在如果你运行pipenv install -d --skip-lock它就会完成。看起来图书馆需要一个版本>= importlib-metadata 2.0。当我固定以下依赖项时,它在运行时一开始不起作用pipenv lock,但是,如果我删除了锁定文件(rm Pipenv.lock),那么当我pipenv lock再次运行时它就起作用了。virtualenv = "==20.0.31"importlib-metadata = "==1.7.0"

守候你守候我

Pipefile.lock尝试在安装包之前删除

凤凰求蛊

只需删除Pipfile.lock然后重新运行即可pipenv lock。

米脂

我在使用 python 3.7.12 创建虚拟环境时遇到了同样的问题。使用 python 3.8.10 问题就消失了。在 Ubuntu 20.04.4 LTS 上。

鸿蒙传说

以下是我们在遇到“锁定失败”时遵循的一些步骤1.make env 2.source /etc/pyenv 3.pipenv install 4.pipenv graph 5. 拍摄相应的测试用例执行(可能会根据需求而有所不同)希望它有效!:)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python