2017-12-01 Python and PyPI

I recently rewrote my Mastodon Archive tool to be uploaded to PyPI. Steve Ivy provided the initial push and code, as you can see in this Mastodon thread. But eventually I was stuck.

I was setting up Travis CI to publish my code to PyPI and I was seeing “UnicodeEncodeError: latin-1” at the very end of the deployment. I didn’t know what I was doing. Everything finished without an error?

I decided to give this a try myself, locally. Mark Pilgrim had written something about Packaging Python Libraries but I always ended up with an error:

$ python3 setup.py sdist upload
running upload
Submitting dist/mastodon_archive-0.0.1.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

Finally, Joe Friedl was able to help me, as you can see in this Mastodon thread. The official documentation on Uploading your Project to PyPI had already mentioned twine. Apparently we no longer use python3 setup.py sdist upload – now it’s python3 setup.py sdist and twine upload dist/*.

Installing twine ran into a permission issue on this laptop (running macOS and Homebrew):

$ pip3 install twine
PermissionError: [Errno 13] Permission denied: '/usr/local/man'
$ sudo mkdir  /usr/local/man
$ sudo chown alex /usr/local/man
$ pip3 install twine
$ twine upload dist/mastodon_archive-0.0.1.tar.gz 
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: kensanata
Enter your password: 
Uploading mastodon_archive-0.0.1.tar.gz


And I can tear down the Travis CI integration. :)

Here it is: mastodon-archive.



Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.