Notification texts go here Contact Us Buy Now!

Python27(win): import daemon, but there is an error: No module named pwd

  • The pwd Module:

    The pwd module is a UNIX-only package used for managing passwords. It is not available on Windows, which is why you are encountering the error "No module named pwd" when trying to import it.

  • The daemon Package:

    The package you are attempting to install, daemon, is an unmaintained package from 2014 with a more recent and well-maintained alternative called python-daemon. However, both packages depend on the pwd module, which is not available on Windows.

  • Implementing Daemons on Windows:

    If you want to create a daemon on Windows, you need to install it as a service rather than a daemon. This can be achieved by following the steps outlined in the provided StackOverflow post, which remains relevant despite its age.

To handle this error and disable daemon mode on Windows, you can use the following code:

try:
    import daemon
except ImportError:
    daemon = None

You can then check if daemon is None to determine if daemon mode is available.

Additional Information:

  • pwd Module Alternative:

    Since the pwd module is not available on Windows, you can use the getpass module to retrieve the current user's name. However, this module may also require modifications to work on Windows.

  • Repairing Python Installation:

    If you encounter the "module pwd not found" error even when using the getpass module, you can attempt to repair your Python installation using the installer.

  • Avoiding pwd Module Usage:

    If you are using a package like Pebblo, you can avoid the pwd module by commenting out its import statement in the pebblo.py file.

By following these steps and considering the provided alternatives, you can resolve the "No module named pwd" error and manage daemons or services effectively on Windows.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.