我正在将一个具有PyPDF2要求的项目上载到pypi。
但是在测试上传时,发生以下错误:
(env) C:\Users\mique\Projects\test>pip install --index-url https://test.pypi.org/simple/ pdf_text_searcher
Looking in indexes: https://test.pypi.org/simple/
Collecting pdf_text_searcher
Downloading https://test-files.pythonhosted.org/packages/3f/b9/5692afe36e11d2c237e8c598cfb3462f2251daed6c0f039b4c2c6af28113/pdf_text_searcher-0.0.6-py3-none-any.whl
Collecting PyPDF2 (from pdf_text_searcher)
Could not find a version that satisfies the requirement PyPDF2 (from pdf_text_searcher) (from versions: )
No matching distribution found for PyPDF2 (from pdf_text_searcher)
这是我的setup.py文件:
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="pdf_text_searcher",
version="0.0.6",
author="Miquel Vande Velde",
author_email="miquel.vandevelde@gmail.com",
description="CLI Tool to search words in multiple PDFs within a directory.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/miquel-vv/pdf_searcher",
entry_points = {
'console_scripts': ['pdf-text-searcher=pdf_text_searcher.search_directory:main']
},
install_requires = ['PyPDF2'],
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
我尝试同时使用'PyPDF2==1.26.0'
和'PyPDF2>=1.26.0'
指定PyPDF2的版本。但是,同样的错误不断发生。
已解决
正如@unutbu和@stofvl在评论中指出的那样,我应该使用--extra-index-url标志而不是--index-url。
-index-url告诉pip只在提供的索引中查找包(在我的例子中为test.pypi),因此由于未在其中找到依赖关系而出错。
-extra-index-url告诉pip查看提供的索引和默认的pypi索引。