使用pipenv安装软件包时出现Pipfile.lock错误

问题描述 投票:0回答:1

我正在尝试使用Python 3.11.4创建一个虚拟环境,其中包含以下软件包:

numpy 1.25.2, pandas 2.0.3, requests 2.31.0
jupyterlab 4.0.5
,我可以在其中运行jupyterlab并使用jupyter笔记本。

我创建了很好的虚拟环境。

当我尝试安装特定版本的软件包时,在运行中但没有创建 Pipfile.lock。我收到此错误消息:

Installing numpy...
Resolving numpy...
Added numpy to Pipfile's [packages] ...
✔ Installation Succeeded
Installing 1.25.2...
Resolving 1.25.2...
Added 1.25.2 to Pipfile's [packages] ...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
⠙ Locking packages...False
<console width=124 ColorSystem.TRUECOLOR>
Traceback (most recent call last):
  File "/Users/anaconda3/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/cli/options.py", line 52, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/cli/command.py", line 207, in install
    do_install(
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/routines/install.py", line 234, in do_install
    raise e
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/routines/install.py", line 209, in do_install
    do_init(
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/routines/install.py", line 649, in do_init
    do_lock(
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/routines/lock.py", line 67, in do_lock
    venv_resolve_deps(
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 859, in venv_resolve_deps
    c = resolve(cmd, st, project=project)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anaconda3/lib/python3.11/site-packages/pipenv/utils/resolver.py", line 723, in resolve
    raise RuntimeError("Failed to lock Pipfile.lock!")
RuntimeError: Failed to lock Pipfile.lock!

我可以在不指定版本的情况下安装 numpy 并且它可以工作,但是当我尝试指定版本时却不能。我尝试安装的所有软件包都会发生这种情况。

我尝试直接编辑pipfile,然后使用pipenv同步,它说它已同步,但是当我运行pipenv graph时,我需要的版本不在我的全局环境中。

我还尝试过 pipelinev lock 来创建锁定文件,但是当我尝试在指定的版本下安装软件包时,我收到相同的“

failed to lock Pipfile.lock!
”消息。我也使用了 verbose,同样的事情发生了。

为什么这些软件包版本无法安装 - 这是依赖项问题吗?我认为这不会造成 Pipfile.lock 问题。这也是一个作业,所以我需要在我的 venv 中使用这些特定的包。

python pipenv pipenv-install pipfile pyenv-virtualenv
1个回答
0
投票

我也有同样的问题!我收到“无法锁定 pipfile.lock!”错误,即使我使用 pipelinev 锁创建 pipfile.lock。

© www.soinside.com 2019 - 2024. All rights reserved.