Python Forum
getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY'
#4
I fixed it by simply modifiying getpass.py like this:
Adding "import msvcrt" to the imports in the first lines of the module
And mofying the last code line (an else statement) to "getpass = win_getpass"

"""Utilities to get a password and/or the current user name.

getpass(prompt[, stream]) - Prompt for a password, with echo turned off.
getuser() - Get the user name from the environment or password database.

GetPassWarning - This UserWarning is issued when getpass() cannot prevent
                 echoing of the password contents while reading.

On Windows, the msvcrt module will be used.

"""

# Authors: Piers Lauder (original)
#          Guido van Rossum (Windows support and cleanup)
#          Gregory P. Smith (tty support & GetPassWarning)

import contextlib
import io
import os
import sys
import warnings
import msvcrt # added

# ...

else:
    getpass = win_getpass # unix_getpass
This might have broken Unix support but I don't really care since I use Windows.
Reply


Messages In This Thread
RE: getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' - by EarthAndMoon - Oct-03-2023, 07:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 1,976 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 843 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 4,288 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,618 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 6,055 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  AttributeError: 'numpy.ndarray' object has no attribute 'load' hobbyist 8 7,358 Jul-06-2022, 10:55 AM
Last Post: deanhystad
  AttributeError: 'numpy.int32' object has no attribute 'split' rf_kartal 6 4,618 Jun-24-2022, 08:37 AM
Last Post: Anushka00
  AttributeError: 'list' object has no attribute 'upper' Anldra12 4 5,095 Apr-27-2022, 09:27 AM
Last Post: Anldra12
  AttributeError: 'function' object has no attribute 'metadata 3lnyn0 5 4,843 Mar-28-2022, 04:42 PM
Last Post: Larz60+
  Module 'time' has no attribute 'clock' Sophie 4 3,257 Jan-25-2022, 08:05 PM
Last Post: Sophie

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020