【发布时间】:2021-12-06 02:17:03
【问题描述】:
我已经为我的 project1 安装了版本 1.2.0 的 kafka 包,当我为 project2 安装版本 1.3.0 时,之前的版本被覆盖,然后 project1 将无法运行, 我可以做些什么来保持这两个项目正常运行?
D:\soar\totems-siip-soar-plugins\totems-siip-soar-plugins-pycommon>pip show kafka
Name: kafka
Version: 1.2.0
Summary: Pure Python client for Apache Kafka
Home-page: https://github.com/dpkp/kafka-python
Author: Dana Powers
Author-email: dana.powers@gmail.com
License: Apache License 2.0
Location: c:\users\administrator\appdata\local\programs\python\python39\lib\site-packages
Requires: six
Required-by: totems-pycommon
当我安装其他版本时:
D:\soar\totems-siip-soar-plugins\totems-siip-soar-plugins-pycommon>pip install kafka==1.3.0
Looking in indexes: http://192.168.218.125:8081/repository/pypi_group_test/simple
Collecting kafka==1.3.0
Downloading http://192.168.218.125:8081/repository/pypi_group_test/packages/kafka/1.3.0/kafka-1.3.0-py2.py3-none-any.whl (193 kB)
|████████████████████████████████| 193 kB ...
Installing collected packages: kafka
Attempting uninstall: kafka
Found existing installation: kafka 1.2.0
Uninstalling kafka-1.2.0:
Successfully uninstalled kafka-1.2.0
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.
totems-pycommon 1.0.0 requires kafka==1.2.0, but you have kafka 1.3.0 which is incompatible.
Successfully installed kafka-1.3.0
【问题讨论】:
-
你可以使用 virtualenv
-
使用 conda 环境。这使您可以为每个项目设置一个单独的 python 环境,如果需要,可以使用不同的 python 版本
-
你可以使用
pkg_resources在运行时维护不同版本的需求,虽然它有局限性。看看这个packaging.python.org/guides/multi-version-installs -
@QuantumMecha 谢谢,我尝试将我的项目部署在多个 conda 环境中,它们不会相互影响
标签: python installation pip version