当安装一个项目时,我试图限制ipykernel
包的可接受版本的范围,该项目有一个需要"setuptools>=45"
的pyproject.toml
文件和一个setup.cfg
文件,该文件具有以下install_requires
选项:
install_requires =
nexusformat >= 0.7.5
numpy
scipy
h5py >= 2.9
qtpy
qtconsole
ipython
ipykernel <= 6.8.0, >= 6.15.2
这会触发以下错误消息:
$ pip install -e .
Obtaining file:///Users/rosborn/Documents/Computing/Repositories/nexpy
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: matplotlib in /Users/rosborn/opt/miniconda3/envs/py38/lib/python3.8/site-packages (from NeXpy==0.14.6.dev6+g9996d70.d20220829) (3.6.0rc1)
ERROR: Could not find a version that satisfies the requirement ipykernel<=6.8.0,>=6.15.2 (from nexpy)
(from versions: 4.0.1, 4.0.2, 4.0.3, 4.1.0, 4.1.1, 4.2.0, 4.2.1, 4.2.2,
4.3.0, 4.3.1, 4.4.0, 4.4.1, 4.5.0, 4.5.1, 4.5.2, 4.6.0, 4.6.1, 4.7.0,
4.8.0, 4.8.1, 4.8.2, 4.9.0, 4.10.0, 4.10.1, 5.0.0b1, 5.0.0, 5.1.0,
5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.2.0, 5.2.1, 5.3.0, 5.3.1, 5.3.2, 5.3.3,
5.3.4, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.5.0, 5.5.3, 5.5.4, 5.5.5, 5.5.6,
6.0.0a0, 6.0.0a1, 6.0.0a2, 6.0.0a3, 6.0.0a4, 6.0.0a5, 6.0.0a6, 6.0.0b0,
6.0.0rc0, 6.0.0rc1, 6.0.0rc2, 6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.1.0, 6.2.0,
6.3.0, 6.3.1, 6.4.0, 6.4.1, 6.4.2, 6.5.0, 6.5.1, 6.6.0, 6.6.1, 6.7.0,
6.8.0, 6.9.0, 6.9.1, 6.9.2, 6.10.0, 6.11.0, 6.12.0, 6.12.1, 6.13.0,
6.13.1, 6.14.0, 6.15.0, 6.15.1, 6.15.2)
ERROR: No matching distribution found for ipykernel<=6.8.0,>=6.15.2
换句话说,错误消息列出了它声称无法匹配的版本。甚至在已经安装了ipykernel v6.8.0
或ipykernel v6.15.2
时也会发生这种情况。
我看到过类似的StackOverflow问题(例如,在这里(,但即使有详细的输出,我也没有看到相同的setuptools错误。设置不连续的范围有问题吗?或者另一个语法错误?欢迎提出任何建议。
我在Python 3.8中运行setuptools v65.3.0
和pip 22.2.2
。
不幸的是,使用范围说明符无法实现您想要实现的目标,因为< <= > >=
(在pip
、setuptools
等中(的使用是用逻辑AND
-ing而不是逻辑OR
-ing完成的。改善这方面的努力停滞不前。
因此,根据您的需求:
我需要排除
6.9
和6.15.1
之间的版本,
您必须使用版本排除说明符!=
来排除不想要的版本。
这一行就足够了,并且排除了6.9.*
和6.15.1
之间的ipykernel
的所有释放。
ipykernel != 6.9.*, != 6.10.*, != 6.11.*, != 6.12.*, != 6.13.*, != 6.14.*, != 6.15.0, != 6.15.1
你会发现,在你的情况下,这与安装配合使用。。。
# Done with fresh Python env, installs latest
> pip install "ipykernel != 6.9.*, != 6.10.*, != 6.11.*, != 6.12.*, != 6.13.*, != 6.14.*, != 6.15.0, != 6.15.1"
Collecting ipykernel!=6.10.*,!=6.11.*,!=6.12.*,!=6.13.*,!=6.14.*,!=6.15.0,!=6.15.1,!=6.9.*
Collecting ipykernel-6.15.2-py3-none-any.whl
Downloading ipykernel-6.15.2-py3-none-any.whl (132 kB)
... etc ...
Installing collected packages: wcwidth, pure-eval, ptyprocess, pickleshare, executing, backcall, appnope, traitlets, tornado, six, pyzmq, pyparsing, pygments, psutil, prompt-toolkit, pexpect, parso, nest-asyncio, entrypoints, decorator, debugpy, python-dateutil, packaging, matplotlib-inline, jupyter-core, jedi, asttokens, stack-data, jupyter-client, ipython, ipykernel
Successfully installed appnope-0.1.3 asttokens-2.0.8 backcall-0.2.0 debugpy-1.6.3 decorator-5.1.1 entrypoints-0.4 executing-1.0.0 ipykernel-6.15.2 ipython-8.4.0 jedi-0.18.1 jupyter-client-7.3.5 jupyter-core-4.11.1 matplotlib-inline-0.1.6 nest-asyncio-1.5.5 packaging-21.3 parso-0.8.3 pexpect-4.8.0 pickleshare-0.7.5 prompt-toolkit-3.0.30 psutil-5.9.1 ptyprocess-0.7.0 pure-eval-0.2.2 pygments-2.13.0 pyparsing-3.0.9 python-dateutil-2.8.2 pyzmq-23.2.1 six-1.16.0 stack-data-0.5.0 tornado-6.2 traitlets-5.3.0 wcwidth-0.2.5
尝试安装较旧的ipykernel
# Let's try with installing an older ipykernel and then trying our new specifiers
> pip install ipykernel==6.7.0
Collecting ipykernel==6.7.0
# stuff
Successfully installed appnope-0.1.3 asttokens-2.0.8 backcall-0.2.0 debugpy-1.6.3 decorator-5.1.1 entrypoints-0.4 executing-1.0.0 ipykernel-6.7.0
> pip install "ipykernel != 6.9.*, != 6.10.*, != 6.11.*, != 6.12.*, != 6.13.*, != 6.14.*, != 6.15.0, != 6.15.1"
Requirement already satisfied: ipykernel!=6.10.*,!=6.11.*,!=6.12.*,!=6.13.*,!=6.14.*,!=6.15.0,!=6.15.1,!=6.9.*
in ./.venv/lib/python3.10/site-packages (6.7.0)