Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'pidfile' has no attribute 'PIDFile' #15

Open
Jachimo opened this issue Apr 25, 2023 · 1 comment
Open

AttributeError: module 'pidfile' has no attribute 'PIDFile' #15

Jachimo opened this issue Apr 25, 2023 · 1 comment

Comments

@Jachimo
Copy link

Jachimo commented Apr 25, 2023

This may be user error vs. a bug, but if so maybe a documentation update could be made to explain what I'm doing wrong?

import pidfile
import sys
import time

def main():
    time.sleep(5)

if __name__ == '__main__':
    print('Initializing process')
    try:
        with pidfile.PIDFile('/var/run/myprogram.pid'):
            print('Creating PID file...')
            main()
    except pidfile.AlreadyRunningError:
        print('Program already running!')
        sys.exit(1)
    sys.exit(0)

Based on the documentation, I expected the above to work, but it doesn't. Instead, I get AttributeError: module 'pidfile' has no attribute 'PIDFile'.

This is with Python 3.9.2 on Linux 5.15.84, aarch64 (Raspberry Pi), everything is straight from the Raspbian repos on a clean installation.

@atlantageek
Copy link

Hey, had the same issue.
Make sure you didn't do a pip3 pidfile. This is some other library.
what you want to do is pip3 install python-pidfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants