将 requirements.txt 安装到虚拟环境中

时间:2021-04-14 19:15:07

标签: python-3.x virtualenv

我有一个包含脚本 *.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'

1 个答案:

答案 0 :(得分:0)

您可能想尝试降级 pytz

pip install -Iv pytz==2017.0

或者升级 babel 和 gitsome

sudo pip install babel --upgrade
sudo pip install gitsome --upgrade
相关问题