python setup.py寄存器无法解码位置0的字节0xff

时间:2018-08-09 08:35:26

标签: python pypi sdist

我正在打包我的python代码,希望上传到我的pypi, 我的setup.py就像这样:

#!/usr/bin/env python
from __future__ import print_function
from setuptools import setup, find_packages
import sys

setup(
    name="JsonGet",
    version="0.2.0",
    author="Dennis Wang",
    author_email="dennis.wang@detvista.com",
    license="Apache License",
    url="https://github.com/cortexiphan1/JsonGet",
    packages=["JsonGet"],
    install_requires=["simplejson"],
    classifiers=[
        "Environment :: Web Environment",
        "Intended Audience :: Developers",
        "Operating System :: OS Independent",
        "Topic :: Text Processing :: Indexing",
        "Topic :: Utilities",
        "Topic :: Internet",
        "Topic :: Software Development :: Libraries :: Python Modules",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3.6"
    ],
)

然后我成功运行了这些命令

python setup.py sdist
python setup.py install 

之后,我可以导入我的包并制作一个测试用例。

但是当我注册并上传到pypi时,它会引发此解码错误, 我已经搜索并尝试了很多次,所有文件均由utf-8编码。

当我通过Powershell在Windows上使用这些命令时,它会抛出 “ gbk”编解码器无法解码。

我不确定实际发生了什么,我是第一次将代码上传到pypi ...

(py3) [root@detvista JsonGet]# python setup.py register sdist upload
    running register
    running egg_info
    writing JsonGet.egg-info/PKG-INFO
    writing dependency_links to JsonGet.egg-info/dependency_links.txt
    writing requirements to JsonGet.egg-info/requires.txt
    writing top-level names to JsonGet.egg-info/top_level.txt
    reading manifest file 'JsonGet.egg-info/SOURCES.txt'
    writing manifest file 'JsonGet.egg-info/SOURCES.txt'
    Traceback (most recent call last):
      File "setup.py", line 25, in <module>
        "Programming Language :: Python :: 3.6"
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/site-packages/setuptools/command/register.py", line 10, in run
        orig.register.run(self)
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/distutils/command/register.py", line 45, in run
        self._set_config()
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/distutils/command/register.py", line 71, in _set_config
        config = self._read_pypirc()
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/distutils/config.py", line 57, in _read_pypirc
        config.read(rc)
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/configparser.py", line 697, in read
        self._read(fp, filename)
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/configparser.py", line 1015, in _read
        for lineno, line in enumerate(fp, start=1):
      File "/home/pyadmin/anaconda3/envs/py3/lib/python3.6/codecs.py", line 321, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

1 个答案:

答案 0 :(得分:0)

问题似乎出在512 * 32767 ~ 10MB中。也就是说,有问题的文件是您的SELECT b.*, IF(ub.ub_bookid IS NOT NULL, ub.ub_default, 0) AS 'default', IF(ub.ub_bookid IS NOT NULL, True, False) AS 'visible' FROM books b LEFT JOIN users_books ub ON b.b_id = ub.ub_bookid AND ub.ub_userid = :userid 。编辑文件并确认其采用UTF-8编码,并且不包含过多的字符(如字节顺序标记)。