【问题标题】:Installing requirements.txt into virtual environment将 requirements.txt 安装到虚拟环境中
【发布时间】:2021-04-14 19:15:07
【问题描述】:

我有一个包含脚本 *.py 的目录,我需要在另一台包含不同版本模块的计算机上编译它。我在该目录中打开了终端并创建了要求:

pip freeze > requirements.txt 

然后我创建了一个虚拟环境并尝试从 requirements.txt 安装包

virtualenv compilation
source compilation/bin/activate
python3.6 -m pip install -r requirements.txt

以这样的方式结束:

ERROR: Cannot install babel==2.7.0, gitsome==0.8.4 and pytz==2021.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested pytz==2021.1
    babel 2.7.0 depends on pytz>=2015.7
    gitsome 0.8.4 depends on pytz<2017.0 and >=2016.3

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

请问为什么这些包在非虚拟python3.6中工作时会发生冲突?请问这个怎么办?

babel 和 gitsome 升级后

ERROR: Cannot install babel==2.7.0, gitsome==0.8.4, pandas==1.1.5 and pytz==2016.10 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested pytz==2016.10
    babel 2.7.0 depends on pytz>=2015.7
    gitsome 0.8.4 depends on pytz<2017.0 and >=2016.3
    pandas 1.1.5 depends on pytz>=2017.2

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

降级 pytz

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pandas 1.1.5 requires pytz>=2017.2, but you have pytz 2015.7 which is incompatible.
gitsome 0.8.4 requires pytz<2017.0,>=2016.3, but you have pytz 2015.7 which is incompatible.
Successfully installed pytz-2016.10
Removed build tracker: '/tmp/pip-req-tracker-8c5_ezeo'

【问题讨论】:

  • 看起来 babel 和 gitsome 依赖于比您安装的 pytz 更旧的 pytz 版本。也许将 pytz 降级到一个版本或 --upgrade 你的其他两个包

标签: python-3.x virtualenv


【解决方案1】:

您可能想尝试降级 pytz

pip install -Iv pytz==2017.0

或者升级 babel 和 gitsome

sudo pip install babel --upgrade
sudo pip install gitsome --upgrade

【讨论】:

  • 谢谢,我在问题中添加了结果
  • 如果您遵循本指南pip.pypa.io/en/latest/user_guide/…,它可能有助于更好地解释它,但您必须尝试获得正确的 pytz 版本,以便一切都满意。但看起来我 gitsome 和 pandas 现在发生了冲突
  • 感谢您的链接。但是,为什么冲突只发生在虚拟环境中呢?
  • 您的虚拟环境是一个紧密结合的地方,您的代码可以在其中找到所有依赖项按预期运行。您可以让您的代码在 VE 之外工作,因为其他依赖项可以通过在您的 VE 之外安装的 pip 获得
猜你喜欢
  • 2013-05-19
  • 2015-10-02
  • 1970-01-01
  • 1970-01-01
  • 2017-07-10
  • 2016-09-11
  • 2019-05-16
  • 2018-08-04
  • 1970-01-01
相关资源
最近更新 更多