python 自动安装依赖,如何让PyPI自动安装依赖项

How can I publish a package on PyPI such that all dependencies are automatically installed, rather than manually by the user.

I specify the dependencies in setup.py with install_requires as follows:

setuptools.setup(name='myPackage',

version='1.0',

packages=setuptools.find_packages(),

include_package_data=True,

classifiers=[

'Programming Language :: Python :: 3',

'Operating System :: OS Independent',

'Topic :: Scientific/Engineering :: Bio-Informatics'

],

install_requires=['numpy', 'pandas', 'sklearn'],

python_requires='>=3'

)

And I have a requirements.txt file which is included in my MANIFEST.in:

numpy==1.15.4

sklearn==0.20.1

pandas==0.23.4

However, after publishing on test.pypi when I try to install the package, I get the following error:

Could not find a version that satisfies the requirement numpy (from myPackage==1.0.0) (from versions: )

No matching distribution found for sklearn (from myPackage==1.0.0)

This means that PyPI does not install the numpy dependency.

How do I enable automatic installation of my dependencies?

Should I use a virtual environment when building and publishing the package? How do I do this?

P.S. I am entirely new to this so I will appreciate explicit code or links to simple tutorial pages. Thank you.

解决方案

I realized that installing packages from test.PyPI does not install all packages, since some of these packages are hosted on PyPI and not test.PyPI.

When I published the package on PyPI as a pre-release version (1.0a1), instead on test.PyPI, the dependencies were correctly installed. Hence, the problem was purely with test.PyPI.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值