Updating a package on pypi

1 minute read

Detailed instructions can be found here


  • You have updated a Python package, for example to add a feature or fix a bug
  • You have an up-to-date local repository and have pushed all changes to GitHub
  • You have incremented the version number for the package
  • You have accounts on pypi and test.pypi

You will need to have in your repository (see link above):

  • a suitably-configured setup.py file
  • a README.md file (this will be your pypi documentation page)
  • a LICENSE file
  • If these are not present, add them now

1: Update local packages for distribution

python -m pip install --user --upgrade setuptools wheel
python -m pip install --user --upgrade twine

2: Create distribution packages on your local machine, and check the dist/ directory for the new version files

python setup.py sdist bdist_wheel
ls dist

3: Upload the distribution files to pypi’s test server

python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

4: Test the upload with a local installation

Create a new test environment

conda create --name test_pypi python=3.8
  • Install your package from the test server
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps <PACKAGE>
- Start Python, import the package, and test the version

5: Upload the distribution files to pypi

python -m twine upload dist/*
  • Check the upload at pypi
    • [https://pypi.org/project///](https://pypi.org/project///)