我在Docker容器中使用pipenv
。我试着安装一个包,发现安装成功了(被添加到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)
File "/usr/local/lib/python3.7/site-packages/pipenv/environment.py", line 122, in resolve_dist
deps |= cls.resolve_dist(dist, working_set)
File "/usr/local/lib/python3.7/site-packages/pipenv/environment.py", line 121, in resolve_dist
dist = working_set.find(req)
File "/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.7/site-packages/pkg_resources/__init__.py", line 642, in find
raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 2.0.0 (/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.7/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
(app) root@7284b7892266:/usr/src/app#
会有什么问题呢?
编辑删除Pipfile.lock
并尝试安装一个软件包后,我得到:
(app) root@ef80787b5c42:/usr/src/app# pipenv install httpx
Installing httpx…
Adding httpx to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Building requirements...
Resolving dependencies...
✔ Success!
Locking [packages] dependencies…
Building requirements...
⠏ Locking...Resolving dependencies...
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pipenv/cli/command.py", line 252, in install
site_packages=state.site_packages
File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 2202, in do_install
skip_lock=skip_lock,
File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1303, in do_init
pypi_mirror=pypi_mirror,
File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1113, in do_lock
keep_outdated=keep_outdated
File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 1323, in venv_resolve_deps
c = resolve(cmd, sp)
File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 1136, in resolve
result = c.expect(u"\n", timeout=environments.PIPENV_INSTALL_TIMEOUT)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/delegator.py", line 215, in expect
self.subprocess.expect(pattern=pattern, timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/pexpect/spawnbase.py", line 344, in expect
timeout, searchwindowsize, async_)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/pexpect/spawnbase.py", line 372, in expect_list
return exp.expect_loop(timeout)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/pexpect/expect.py", line 181, in expect_loop
return self.timeout(e)
File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/pexpect/expect.py", line 144, in timeout
raise exc
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x7f81e99bec90>
searcher: searcher_re:
0: re.compile('\n')
<pexpect.popen_spawn.PopenSpawn object at 0x7f81e99bec90>
searcher: searcher_re:
0: re.compile('\n')
(app) root@ef80787b5c42:/usr/src/app#
6条答案
按热度按时间v1uwarro1#
这是我的调试笔记。仍然不确定是哪个软件包导致了这个问题,但这似乎解决了它。
第一次使用pipenv版本
2020.8.13
运行pipenv install
时出现的错误。如果运行
pip install -U pipenv
,似乎会更改importlib-metadata
版本:现在如果你运行
pipenv install -d --skip-lock
,它将完成。似乎一个库需要>= importlib-metadata 2.0
版本。当我固定以下依赖项时,它在运行
pipenv lock
时最初不工作,但是,如果我删除锁定文件(rm Pipenv.lock
),那么当我再次运行pipenv lock
时,它就工作了。fxnxkyjh2#
在安装软件包之前尝试删除
Pipefile.lock
swvgeqrz3#
我在使用python 3.7.12创建虚拟环境时遇到了同样的问题。这个问题在Python 3.8.10中解决了。在Ubuntu 20.04.4 LTS上。
3pvhb19x4#
--删除项目中的Pipfile--运行$pipenv lock
这个应该能用在删除之前,您还可以尝试$pipenv lock --pre
jaql4c8m5#
以下是我们在遇到“锁定失败”时遵循的一些步骤
1./etc/pypenv/pipenv拍摄相应的测试用例执行(可能会因需求而异)
希望能成功!!!:)
igsr9ssn6#
只需删除
Pipfile.lock
,然后删除pipenv lock
。