python27(win): import daemon, but there is an error: no module named pwd

  • Last Update :
  • Techknowledgy :

Your code should detect that this is not available and disable daemon mode on Windows (which isn't really a thing).

try:
import daemon
except ImportError:
   daemon = None

Suggestion : 2

The pwd module is a UNIX only package, anycodings_python it's for managing passwords.,python-daemon (newer version) and daemon anycodings_python both require the pwd package, which is anycodings_python not available on Windows.,Same thing happened to me in getpass anycodings_python module, it worked the first time in anycodings_python getpass.getuser() but then it stopped anycodings_python working saying,Then later, you can check if daemon is anycodings_python None.

2) Open windows cmd and input: python, then anycodings_python input: import daemon the terminal anycodings_python show

>>> import daemon
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
      File "C:\Python27\lib\site-packages\daemon\__init__.py", line 42, in <module>
         from .daemon import DaemonContext
         File "C:\Python27\lib\site-packages\daemon\daemon.py", line 25, in <module>
            import pwd
            ImportError: No module named pwd
            >>>

Your code should detect that this is not anycodings_python available and disable daemon mode on anycodings_python Windows (which isn't really a thing).

try:
import daemon
except ImportError:
   daemon = None

Suggestion : 3

Last updated: Apr 20, 2022

Copied!#👇️ On Linux or MacOS
python - m ensurepip--upgrade

#👇️ using python 3
python3 - m ensurepip--upgrade

#👇️ On Windows
py - m ensurepip--upgrade
Copied!#👇️ make sure to use your version of Python, e.g.3.10
python3 - m pip install requests
Copied!#👇️ On Linux or MacOS
python get - pip.py

#👇️ using python 3
python3 get - pip.py

#👇️ On Windows
py get - pip.py
Copied!#👇️ On Debian / Ubuntu
sudo apt update
sudo apt install python3 - venv python3 - pip

#👇️ On MacOS
brew install python

#👇️ On Fedora / CentOS
sudo dnf install python3 - pip python3 - wheel
Copied!#👇️ on MacOS or Linux
python - m pip install--upgrade pip

#👇️
for Python 3
python3 - m pip install--upgrade pip

#👇️ on Windows
py - m pip install--upgrade pip
Copied!python--version