Q:

python setup.py register can't decode byte 0xff in position 0

I'm packaging my python code and hope to upload to my pypi,
my setup.py is like this:
#!/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"
    ],
)

then I successfully run these commands
python setup.py sdist
python setup.py install 

After these I can import my package and make a test case either.
But while I register and upload to pypi, it throws this decode error,
I have searched and tried many times, all files are encoded by utf-8.
When I am using these commands on windows through powershell, it throws 
'gbk' codec can't decode.
I'm not sure what happened actually, my first time uploading codes to 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

A:

The problem seems to be in self._read_pypirc(). That is, the problematic file is your ~/.pypirc. Edit the file and verify it is in UTF-8 encoding and doesn't contain excessive characters like Byte Order Marks.

