从 PyPI 进行 pip 安装但从 .whl 进行 pip 安装时,包上的 Numpy 安装要求失败

发布于 2025-01-19 08:26:46 字数 1879 浏览 0 评论 0原文

我最近构建了我的第一个Python软件包,并试图通过test.pypi.org( github repo a href =“ https://test.pypi.org/project/project/mathsom/” rel =“ nofollow noreferrer”> test pypi )

代码用于构建dist:

python setup.py sdist bdist_wheel

用于上传的dist:test PYPI的代码:

twine upload --repository testpypi dist/*

然后我创建和创建和创建和空的conda env测试安装:

conda create --prefix ./envs --no-default-packages python=3.6

在此环境中,我使用 susces pip pip安装与车轮文件:

pip install mathsom-0.1.1-py3-none-any.whl

但是,如果我尝试通过test pypi numpy安装安装失败(IN install_requirlements en setup.cfg)文件)。代码:

pip install -i https://test.pypi.org/simple/ mathsom

setup.cfg代码:

[metadata]
name = mathsom
author = Oliver Mohr B.
author_email = [email protected]
version = 0.1.1
description = Personal library for math related problems
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/oliverm91/mathsom
license_files = LICENSE
keywords = solvers, solver, interpolations, interpolation, numerics, derivatives, integrals

[options]
package_dir=
    = src
packages=find:
setup_requires = 
    numpy
install_requires =
    numpy
    scipy

[options.packages.find]
where=src

setup.py

from setuptools import setup
if __name__ == '__main__':
    setup()

第一行错误(极长的错误msg):

I recently build my first python package and tried to test distribution with test.pypi.org (Github repo Test PyPI)

Code for building the dist:

python setup.py sdist bdist_wheel

Code for uploading to Test PyPI:

twine upload --repository testpypi dist/*

Then I created and empty conda env to test the installation with:

conda create --prefix ./envs --no-default-packages python=3.6

In this enviroment I used succesfully pip install with wheel file:

pip install mathsom-0.1.1-py3-none-any.whl

But if I try to install it from Test PyPI numpy installation fails (it is in install_requirements en setup.cfg file). Code:

pip install -i https://test.pypi.org/simple/ mathsom

Setup.cfg code:

[metadata]
name = mathsom
author = Oliver Mohr B.
author_email = [email protected]
version = 0.1.1
description = Personal library for math related problems
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/oliverm91/mathsom
license_files = LICENSE
keywords = solvers, solver, interpolations, interpolation, numerics, derivatives, integrals

[options]
package_dir=
    = src
packages=find:
setup_requires = 
    numpy
install_requires =
    numpy
    scipy

[options.packages.find]
where=src

Setup.py

from setuptools import setup
if __name__ == '__main__':
    setup()

First lines of error (extremly long error msg):
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个ˇ局外人 2025-01-26 08:26:46

如果您查看错误消息,您可以看到

Downloading ... mathsom-0.1.1-py3-none-any.whl

因此它也使用了 whl 文件。但是,numpy 的安装方式有所不同。在您的错误消息中,很明显 numpy 正在尝试从源代码进行编译,这并不奇怪,因为您将索引设置为 https://test.pypi.org/simple/ 并且该索引下只有 numpy 的源发行版。如果您允许从 pypi 中提取依赖项,通过使用 --extra-index-url 将 test.pypi 设置为额外索引,那么一切正常(在使用创建的新 conda 环境中进行测试)您提供的命令):

pip install --extra-index-url https://test.pypi.org/simple/ mathsom
Looking in indexes: https://pypi.org/simple, https://test.pypi.org/simple/
Collecting mathsom
  Downloading https://test-files.pythonhosted.org/packages/4b/b3/76e6bbaa6c1da9f6f032e114af7f5724077154a28b5fc7069330185f2bc8/mathsom-0.1.1-py3-none-any.whl (18 kB)
Collecting scipy
  Downloading scipy-1.5.4-cp36-cp36m-win_amd64.whl (31.2 MB)
     |████████████████████████████████| 31.2 MB 393 kB/s
Collecting numpy
  Downloading numpy-1.19.5-cp36-cp36m-win_amd64.whl (13.2 MB)
     |████████████████████████████████| 13.2 MB ...
Installing collected packages: numpy, scipy, mathsom
Successfully installed mathsom-0.1.1 numpy-1.19.5 scipy-1.5.4

If you look at your error message, you can see

Downloading ... mathsom-0.1.1-py3-none-any.whl

So it is also using a whl file. However, the way numpy is installed differs. In your error message, it is clear that numpy is trying to compile from source, which is not suprising, since you set the index to https://test.pypi.org/simple/ and there is only source distributions of numpy under that index. If you allow that the dependencies can be pulled from pypi, by setting test.pypi as an extra-index with --extra-index-url then everything works (tested in a fresh conda env created with the command you have provided):

pip install --extra-index-url https://test.pypi.org/simple/ mathsom
Looking in indexes: https://pypi.org/simple, https://test.pypi.org/simple/
Collecting mathsom
  Downloading https://test-files.pythonhosted.org/packages/4b/b3/76e6bbaa6c1da9f6f032e114af7f5724077154a28b5fc7069330185f2bc8/mathsom-0.1.1-py3-none-any.whl (18 kB)
Collecting scipy
  Downloading scipy-1.5.4-cp36-cp36m-win_amd64.whl (31.2 MB)
     |████████████████████████████████| 31.2 MB 393 kB/s
Collecting numpy
  Downloading numpy-1.19.5-cp36-cp36m-win_amd64.whl (13.2 MB)
     |████████████████████████████████| 13.2 MB ...
Installing collected packages: numpy, scipy, mathsom
Successfully installed mathsom-0.1.1 numpy-1.19.5 scipy-1.5.4
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文