我正在为我自己的包创建一个setup.py
。我的包需要一个Python依赖项“rarfile”。因此,在setup.py
中,我添加了:
setup(
...
install_requires=[ 'rarfile' ],
)
不幸的是,当我构建包,将其上传到test.pypi,并测试安装时,它会失败,抱怨rarfile没有匹配的发行版。奇怪的是,我可以使用pip3手动安装rarfile,而没有任何问题,而且工作正常。
在我的包上用pip3测试安装:
pip3 install --no-cache-dir --index-url https://test.pypi.org/simple/ droidlysis
Collecting droidlysis
Downloading https://test-files.pythonhosted.org/packages/01/e8/f7542484ba4acd6a2d079a22c29cd88dcf63cd8334ffa3de29fa5b0ea7a0/droidlysis-3.0.11.tar.gz (40kB)
100% |████████████████████████████████| 40kB 975kB/s
Collecting rarfile==3.1 (from droidlysis)
Could not find a version that satisfies the requirement rarfile==3.1 (from droidlysis) (from versions: )
No matching distribution found for rarfile==3.1 (from droidlysis)
直接用rarfile
安装pip3:
$ pip3 install rarfile==3.1
Collecting rarfile==3.1
Using cached https://files.pythonhosted.org/packages/88/0b/107dde3f330d04668e126932a09002ac47348841453aa0391634381fa087/rarfile-3.1.tar.gz
Building wheels for collected packages: rarfile
Running setup.py bdist_wheel for rarfile ... error
Complete output from command /home/axelle/softs/myvirtualenvs/testdroidlysis/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yj6ptg3b/rarfile/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpnlukg8ugpip-wheel- --python-tag cp36:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for rarfile
Running setup.py clean for rarfile
Failed to build rarfile
Installing collected packages: rarfile
Running setup.py install for rarfile ... done
Successfully installed rarfile-3.1
发布于 2020-02-28 05:54:07
问题在于--index-url URL
交换机。
这将取代默认的pypi.org
,并完全忽略它。使用--extra-index-url URL
来考虑默认的pypi.org
pip install
的帮助
...
Package Index Options:
-i, --index-url <url> Base URL of the Python Package Index (default
https://pypi.org/simple). This should point to a
repository compliant with PEP 503 (the simple
repository API) or a local directory laid out in
the same format.
--extra-index-url <url> Extra URLs of package indexes to use in addition
to --index-url. Should follow the same rules as
--index-url.
...
发布于 2020-02-28 05:53:59
--index-url
选项覆盖默认索引url;它没有添加到其中。试着用--extra-index-url
代替:
$ pip3 install --no-cache-dir --extra-index-url https://test.pypi.org/simple/ droidlysis
发布于 2020-02-28 05:53:57
您使用了--index-url https://test.pypi.org/simple/
,因此pip
只查看该索引,而不查看其他索引。
没有https://test.pypi.org/project/rarfile
,所以安装确实失败了。
任一
--index-url
交换机同时包括pypi.org/index
和test.pypi.org/index
、--extra-index-url
将test.pypi.org/index
添加到搜索H 212F 213
的位置上https://stackoverflow.com/questions/60453098
复制相似问题