Help us understand the problem. What is going on with this article?

【Python】PyPIエラー対応 File already existsの対処法

発生したエラー

twineを使って、PythonパッケージをPyPIに登録しようとしたところ、

HTTPError: 400 Client Error: File already exists. See https://pypi.org/help/#file-name-reuse for url: https://upload.pypi.org/legacy/

のエラーとなる。

$ twine upload --repository pypi dist/*
Enter your username: hogefuga
Enter your password: 
Uploading distributions to https://upload.pypi.org/legacy/
Uploading cc
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 11.4k/11.4k [00:01<00:00, 9.14kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 400 Client Error: File already exists. See https://pypi.org/help/#file-name-reuse for url: https://upload.pypi.org/legacy/
$

対処方法

原因は、PyPIに登録済みのパッケージとファイル名が重複してしまっているため。

PyPIには同じバージョンのパッケージを再登録はできない。

setup.pyversionを変更した上で、python setup.py bdist_wheelでパッケージファイルを作り直すことで、登録が可能。

setup.py
#!/usr/bin/env python
# coding: utf-8

from setuptools import setup, find_packages
from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='gokulang',
    packages=['gokulang'],

    version='1.0.1', # 1.0.0 => 1.0.1 に変更
# ...

環境

  • Python 3.6.6
  • twine 1.13.0
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away