twine: Can't enter password in Windows

Your Environment

Thank you for taking the time to report an issue.

To more efficiently resolve this issue, we’d like to know some basic information about your system and setup.

  1. Windows 10

  2. Python 3.8.2

  3. I used pip.(pip install twine)

  4. I don’t know

  5. https://github.com/mathstar13/easyapi

If you’re having issues uploading a specific package, you must include a copy of the following:

  • The package’s PKG-INFO file
  • A redacted version of your .pypirc file (REMOVE ALL USERNAMES & PASSWORDS BEFORE UPLOADING)

The Issue

The issue is that every time I try to upload, I enter __token__ in username, but I can’t enter ANY text in the password field.

Steps to Reproduce

Use wheel on setup.py Type in python -m twine upload --repository testpypi dist/* type in __token__ as the username Try to type in the password

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 49 (23 by maintainers)

Most upvoted comments

@mathstar13 One of these options should work from Command Prompt:

  1. Clicking Edit > Paste from the Command Prompt menu
  2. Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu
  3. Use right-click to paste

Here’s an example of option 1 working for me:

Kapture 2020-08-18 at 12 06 56

In the interest of enabling you to use your token (which is better than username/password) and assisting future Windows Python developers, would you be game to give one of those options a try?

@IVN-tone Excellent! I’m glad you were able to get it working.

One note: after looking at the “properties” suggestion:

  • Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu

I think enabling this means you can use Ctrl+Shift+V to paste in the command prompt, but still not Ctrl+V. To make it more confusing, this only applies to the command prompt, meaning you’d use Ctrl+C to copy the token from your web browser.

@nathanramoscfa I’m not familiar with Anaconda Prompt. To help troubleshoot, it’d be useful to see the exact command you’re running, and the output that you’re seeing. And, assuming you have the Twine v3.3.0 or later, you can run twine upload --verbose ... to see more information that might be useful for debugging.

I figured out what was going on. Your solution works but when doing the top left menu, edit, paste method in Anaconda Prompt, it sometimes doesn’t paste anything the first try. I just hit enter, get the expected authentication error and try a second time. Then it works on the second try. Also, when pasting the password, nothing is visible. It makes it look as if nothing was pasted, but in actuality, it did paste the password, but it seems to be hidden from view…which I guess makes sense for security, but is confusing for first time users. Thanks for your help!

@IVN-tone Excellent! I’m glad you were able to get it working.

One note: after looking at the “properties” suggestion:

  • Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu

I think enabling this means you can use Ctrl+Shift+V to paste in the command prompt, but still not Ctrl+V. To make it more confusing, this only applies to the command prompt, meaning you’d use Ctrl+C to copy the token from your web browser.

Oh, yes, you’re right, I forgot about Shift, that’s was my fault.

@bhrutledge 1 works fine.

@bhrutledge @sigmavirus24 Thanks for helping me out! I got my package uploaded!

I went down the rabbit hole, installed Windows on a virtual machine, and was able to reproduce this when trying to paste the token in Command Prompt or PowerShell. In short, this is a known issue with getpass (and anything that uses it, like Twine) on Windows. The workarounds include:

  • Clicking Edit > Paste from the Command Prompt menu
  • Enabling Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste in the Command Prompt menu
  • Using the new Windows Terminal

@mathstar13 Can you confirm that one of these works for you?

To reproduce, I copied the text pypi-token, and then ran this code to print the length of the entered value:

C:\Users\brian>python -c "import getpass; print(len(getpass.getpass()))"
Password: <ctrl+v><enter>
1

C:\Users\brian>python -c "import getpass; print(len(getpass.getpass()))"
Password: <ctrl+shift+v><enter>
10

Typing works fine:

C:\Users\brian>python -c "import getpass; print(len(getpass.getpass()))"
Password: pypi-token
10

However, I suspect more folks are running into this due to the use of tokens that are difficult to type.

Aside: the SyntaxError in https://github.com/pypa/twine/issues/671#issuecomment-663778973 is due to the single quote; apparently it needs to be a double quote.