我使用 setup.py 创建了自己的包,并上传到 test.pypi.og 上进行测试。我有 3 个版本:1.0.0、1.0.1、1.1.0。 当我想将其安装在新文件夹/项目中时,出现此错误:
ERROR: Cannot install my_package==1.0.0, my_package==1.0.1 and my_package==1.1.0 because these package versions have conflicting dependencies.
The conflict is caused by:
my_package 1.1.0 depends on pysqlite3
my_package 1.0.1 depends on flake8
my_package 1.0.0 depends on flake8
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
但是,如果我多次运行该命令,包的名称(取决于...)会改变!!???
我的 setup.py 的一部分:
python_requires=">=3.8, <4",
packages=find_packages(
include=["sqlalchemy_module"]
),
install_requires=[
"requests",
"pysqlite3",
"SQLAlchemy",
"logging",
"argparse",
"configparser", ],
setup_requires=['setuptools'],
# pip install -e flake8 ... ...
extras_require={
"dev": ['flake8', 'black', 'isort', 'tox', 'mccabe', 'pre-commit', 'bumpver']
},
tests_require=["pytest", "pytest-cov"],
package_data={},
package_dir={"": "."},
谢谢 F.
我在下面的书中找到了这个问题的解决方案: 使用 Python 研究软件工程
基本上,当尝试在 testpypi 上安装包含 testpypi 上不可用的依赖项的包时,我们需要将
--extra-index-url
添加到 pip 命令中。
作为示例,我尝试使用以下命令从 testpypi pip 安装软件包:
$ pip install -i https://test.pypi.org/simple/ spike2py-preprocess==0.0.2
我收到以下错误:
ERROR: Cannot install spike2py-preprocess because these package versions have conflicting dependencies.
The conflict is caused by:
spike2py 0.1.15 depends on matplotlib
spike2py 0.1.14 depends on numpy>=1.19.1
spike2py 0.1.13 depends on matplotlib
spike2py 0.1.12 depends on numpy>=1.19.1
spike2py 0.1.11 depends on numpy==1.19.1
spike2py 0.1.10 depends on numpy==1.19.1
spike2py 0.1.9 depends on matplotlib>=3.3.1
spike2py 0.1.7 depends on matplotlib>=3.3.1
spike2py 0.1.6 depends on matplotlib>=3.3.1
spike2py 0.1.5 depends on matplotlib>=3.3.1
spike2py 0.1.4 depends on matplotlib>=3.3.1
spike2py 0.1.3 depends on matplotlib>=3.3.1
spike2py 0.1.2 depends on matplotlib>=3.3.1
spike2py 0.1.1 depends on matplotlib>=3.3.1
spike2py 0.1.0 depends on matplotlib>=3.3.1
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/topics/dependency-resolution/#dealing-with-dependency-conflicts
但是,当我按如下方式重新运行命令时:
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple spike2py-preprocess==0.0.2
我的软件包已按预期安装。