python-pidfile
                                
                                
                                
                                    python-pidfile copied to clipboard
                            
                            
                            
                        AttributeError: module 'pidfile' has no attribute 'PIDFile'
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.
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