为什么在作为依赖项安装时安装 `pypiwin32` 或 `pywin32` 会失败,但在单独使用 pip 时会成功?
Why does installing `pypiwin32` or `pywin32` fail when installing as a dependency but succeed when just using pip on its own?
我有 setup.py
这样的:
setup(
name='pyomexmeta',
version=version,
license='MIT',
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
author='Ciaran Welsh',
author_email='cwelsh2@uw.edu',
url='https://github.com/sys-bio/libomexmeta',
keywords=['annotation', 'rdf'],
# install_requires=open('requirements.txt').read().split('\n'),
install_requires=["pypiwin32"],
packages=['pyomexmeta'],
package_dir={'pyomexmeta': 'src/pyomexmeta'},
package_data={'pyomexmeta': [
'LICENCE.txt',
] + binaries},
include_package_data=True,
classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
platforms=["Windows", "Linux", "Unix"], # "Mac OS-X", - not yet supported.
)
本题的重要部分在install_requires=['pypiwin32']
。当我尝试在新的 conda 环境中从 testpypi
安装我的包时,出现错误:
PS D:\libOmexMeta> conda create -y --name omex python=3.7
PS D:\libOmexMeta> conda activate omex
PS D:\libOmexMeta> pip install --index-url https://test.pypi.org/simple/ pyomexmeta
我得到的错误是这样的:
ERROR: Could not find a version that satisfies the requirement pypiwin32 (from pyomexmeta) (from versions: none)
ERROR: No matching distribution found for pypiwin32 (from pyomexmeta)
然而,当我这样做时
PS D:\libOmexMeta> pip install pypiwin32
安装成功。
有人知道这是怎么回事吗?
请注意,pywin32
也会发生同样的事情。
通过传递 --index-url https://test.pypi.org/simple
,您将 PIP 的(默认)存储库更改为作为参数给出的存储库。但这似乎因 PyPIWin32 ([PyPI.Test]: Links for pypiwin32) 而被打破。
PyWin32 甚至没有在此处列出。
另一方面,在 pip install pypiwin32
的情况下,它使用了默认存储库,它在其中找到了包并且一切正常。
测试:
[cfati@CFATI-5510-0:e:\Work\Dev\Whosebug\q062697213]> sopr.bat
*** Set shorter prompt to better fit when pasted in Whosebug (or other) pages ***
[prompt]>
[prompt]> :: Search default repo
[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\Scripts\python.exe" -m pip -v search pypiwin32
Getting credentials from keyring for pypi.org
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "POST /pypi HTTP/1.1" 200 200
pypiwin32 (223) -
[prompt]>
[prompt]> :: Search custom repo
[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\Scripts\python.exe" -m pip -v search -i https://test.pypi.org/simple pypiwin32
Getting credentials from keyring for test.pypi.org
Starting new HTTPS connection (1): test.pypi.org:443
https://test.pypi.org:443 "POST /simple HTTP/1.1" 301 205
Looking up "https://test.pypi.org/simple/" in the cache
Current age based on date: 134
Freshness lifetime from max-age: 600
The response is "fresh", returning cached response
600 > 134
ERROR: Exception:
Traceback (most recent call last):
File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\cli\base_command.py", line 186, in _main
status = self.run(options, args)
File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\commands\search.py", line 52, in run
pypi_hits = self.search(query, options)
File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\commands\search.py", line 71, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 1452, in __request
verbose=self.__verbose
File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\network\xmlrpc.py", line 38, in request
return self.parse_response(response.raw)
File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 1342, in parse_response
return u.close()
File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 654, in close
raise ResponseError()
xmlrpc.client.ResponseError: ResponseError()
要解决您的问题,可以:
- 因为您已经安装了依赖项,所以不要尝试通过传递 --no-deps 来安装它们:
pip install --no-deps --index-url https://test.pypi.org/simple pyomexmeta
- 通过传递 --extra-index-url 指定额外的存储库(默认的)(!没有测试一下!)
检查来自 [GitHub]: sys-bio/libOmexMeta - sys-bio.github.io/libsemsim-docs 的注释。
我有 setup.py
这样的:
setup(
name='pyomexmeta',
version=version,
license='MIT',
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
author='Ciaran Welsh',
author_email='cwelsh2@uw.edu',
url='https://github.com/sys-bio/libomexmeta',
keywords=['annotation', 'rdf'],
# install_requires=open('requirements.txt').read().split('\n'),
install_requires=["pypiwin32"],
packages=['pyomexmeta'],
package_dir={'pyomexmeta': 'src/pyomexmeta'},
package_data={'pyomexmeta': [
'LICENCE.txt',
] + binaries},
include_package_data=True,
classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
platforms=["Windows", "Linux", "Unix"], # "Mac OS-X", - not yet supported.
)
本题的重要部分在install_requires=['pypiwin32']
。当我尝试在新的 conda 环境中从 testpypi
安装我的包时,出现错误:
PS D:\libOmexMeta> conda create -y --name omex python=3.7
PS D:\libOmexMeta> conda activate omex
PS D:\libOmexMeta> pip install --index-url https://test.pypi.org/simple/ pyomexmeta
我得到的错误是这样的:
ERROR: Could not find a version that satisfies the requirement pypiwin32 (from pyomexmeta) (from versions: none)
ERROR: No matching distribution found for pypiwin32 (from pyomexmeta)
然而,当我这样做时
PS D:\libOmexMeta> pip install pypiwin32
安装成功。
有人知道这是怎么回事吗?
请注意,pywin32
也会发生同样的事情。
通过传递 --index-url https://test.pypi.org/simple
,您将 PIP 的(默认)存储库更改为作为参数给出的存储库。但这似乎因 PyPIWin32 ([PyPI.Test]: Links for pypiwin32) 而被打破。
PyWin32 甚至没有在此处列出。
另一方面,在 pip install pypiwin32
的情况下,它使用了默认存储库,它在其中找到了包并且一切正常。
测试:
[cfati@CFATI-5510-0:e:\Work\Dev\Whosebug\q062697213]> sopr.bat *** Set shorter prompt to better fit when pasted in Whosebug (or other) pages *** [prompt]> [prompt]> :: Search default repo [prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\Scripts\python.exe" -m pip -v search pypiwin32 Getting credentials from keyring for pypi.org Starting new HTTPS connection (1): pypi.org:443 https://pypi.org:443 "POST /pypi HTTP/1.1" 200 200 pypiwin32 (223) - [prompt]> [prompt]> :: Search custom repo [prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\Scripts\python.exe" -m pip -v search -i https://test.pypi.org/simple pypiwin32 Getting credentials from keyring for test.pypi.org Starting new HTTPS connection (1): test.pypi.org:443 https://test.pypi.org:443 "POST /simple HTTP/1.1" 301 205 Looking up "https://test.pypi.org/simple/" in the cache Current age based on date: 134 Freshness lifetime from max-age: 600 The response is "fresh", returning cached response 600 > 134 ERROR: Exception: Traceback (most recent call last): File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\cli\base_command.py", line 186, in _main status = self.run(options, args) File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\commands\search.py", line 52, in run pypi_hits = self.search(query, options) File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\commands\search.py", line 71, in search hits = pypi.search({'name': query, 'summary': query}, 'or') File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 1112, in __call__ return self.__send(self.__name, args) File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 1452, in __request verbose=self.__verbose File "e:\Work\Dev\VEnvs\py_pc064_03.07.06_test0\lib\site-packages\pip\_internal\network\xmlrpc.py", line 38, in request return self.parse_response(response.raw) File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 1342, in parse_response return u.close() File "c:\Install\pc064\Python\Python.07.06\Lib\xmlrpc\client.py", line 654, in close raise ResponseError() xmlrpc.client.ResponseError: ResponseError()
要解决您的问题,可以:
- 因为您已经安装了依赖项,所以不要尝试通过传递 --no-deps 来安装它们:
pip install --no-deps --index-url https://test.pypi.org/simple pyomexmeta
- 通过传递 --extra-index-url 指定额外的存储库(默认的)(!没有测试一下!)
检查来自 [GitHub]: sys-bio/libOmexMeta - sys-bio.github.io/libsemsim-docs 的注释。