简体   繁体   English

PyPi 断言错误:不支持的架构

[英]PyPi AssertionError: unsupported schema

I'm trying to upload my package to PyPi and came up with this error:我正在尝试将我的 package 上传到 PyPi 并出现此错误:

  Traceback (most recent call last):
  File "setup.py", line 11, in <module>
    author_email= #my email,
  File "C:\Programming\Python\Anaconda\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Programming\Python\Anaconda\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Programming\Python\Anaconda\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Programming\Python\Anaconda\lib\distutils\command\upload.py", line 63, in run
    self.upload_file(command, pyversion, filename)
  File "C:\Programming\Python\Anaconda\lib\distutils\command\upload.py", line 73, in upload_file
    raise AssertionError("unsupported schema " + schema)

Since python setup.py register -r pypitest is no longer needed to upload the package, I run this command: python setup.py sdist upload -r pypitest , and the error comes in after I type in my password for pypitest由于不再需要python setup.py register -r pypitest来上传package,我运行这个命令: python setup.py sdist upload -r pypitest ,输入pypitest的密码后出现错误

Here is how my setup.py and .pypirc files looks like.这是我的setup.py.pypirc文件的样子。

setup.py安装程序.py

from setuptools import setup

setup(
      name='instapi',
      packages=['instapi'],
      version='0.1',
      description='Clean and simple Instagram API for Python 3.x',
      url='https://github.com/SemptraStar/instapi',
      download_url = 'https://github.com/SemptraStar/instapi/archive/v._0.1.tar.gz',
      author= #me,
      author_email= #also me,
)

.pypirc .pypirc

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository=https://pypi.python.org/pypi
username= # username
password= # password

[pypitest]
repository=https://testpypi.python.org/pypi
username= # username
password= # password

UPDATE 1更新 1

I changed repository URL's to https://upload.pypi.org/legacy/ for pypi and https://test.pypi.org/legacy/ for pypitest.我将存储库 URL 更改为https://upload.pypi.org/legacy/ ://upload.pypi.org/legacy/ 用于 pypi 和https://test.pypi.org/legacy/用于 pypitest。 Also updated setuptools for the latest version (36.3.0).还更新了最新版本 (36.3.0) 的设置工具。 Nothing changed.没有改变。

在主目录C:\\Users\\<username>添加.pypirc文件,除了从项目的根目录,对我.pypirc

What you need to do is use twine.你需要做的是使用麻线。 Make sure the version is 1.8+确保版本是 1.8+

  1. Install it via pip install twine通过pip install twine
  2. Make sure your .pypirc file has the correct credentials for test.pypi.org because that is a separate database from production pypi.确保您的 .pypirc 文件具有 test.pypi.org 的正确凭据,因为它是与生产 pypi 不同的数据库。
  3. Build your sdist python setup.py sdist .构建您的 sdist python setup.py sdist
  4. Use twine upload --repository pypitest dist/* for your test upload.使用twine upload --repository pypitest dist/*进行测试上传。
  5. Use twine upload --repository pypi dist/* for your production upload.使用twine upload --repository pypi dist/*进行生产上传。

Had the same issue and solved it by specifying where the .pypirc file is located.有同样的问题并通过指定 .pypirc 文件所在的位置来解决它。 Per default, it is expected in ~./, but you might want to have it stored in your project.默认情况下,它应该在 ~./ 中,但您可能希望将其存储在您的项目中。

This issue helped me here: Custom location for .pypirc file这个问题在这里帮助了我: Custom location for .pypirc file

I was having some trouble with those before as well, though I can't recall if it's the same exactly issue you are describing.我之前也遇到过一些问题,但我不记得这是否与您所描述的问题完全相同。 The old URLs should redirect to the new, but PyPi has moved so there's a chance these won't always work.旧的 URL 应该重定向到新的,但 PyPi 已经移动,所以这些可能并不总是有效。

Try this for pypi server:试试这个 pypi 服务器:

https://upload.pypi.org/legacy/

And this one for pypitest:这是 pypitest 的:

https://test.pypi.org/legacy/

The official documentation of setuptools says setuptools的官方文档

Uploading your package to PyPI将您的 package 上传到 PyPI

After generating the distribution files, the next step would be to upload your distribution so others can use it.生成分发文件后,下一步就是上传您的分发文件,以便其他人可以使用它。 This functionality is provided by twine and is documented in the Python packaging tutorial.此功能由 twine 提供,并记录在 Python 打包教程中。

So I suppose no point in trying to debug setuptools upload issues.所以我想尝试调试 setuptools 上传问题没有意义。 Build using setuptools and upload using twine.使用 setuptools 构建并使用 twine 上传。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM