Python multiprocessing: Permission denied

前端 未结 3 903
暗喜
暗喜 2020-11-28 07:53

I\'m getting an error when trying to execute python program that uses multiprocessing package:

  File \"/usr/local/lib/python2.6/multiprocessing/__init__.py\         


        
相关标签:
3条回答
  • 2020-11-28 08:19

    For POSIX semaphores to work, the users need r/w access to shared memory (/dev/shm).

    Check the permissions to /dev/shm. On my laptop (Ubuntu) it looks like this:

    $ ls -ld /dev/shm
    drwxrwxrwt 2 root root          40 2010-01-05 20:34 shm
    

    To permanently set the correct permissions (even after a reboot), add the following to your /etc/fstab:

    none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0
    

    Haven't tried this, just copied from a forum post.

    0 讨论(0)
  • 2020-11-28 08:29

    In my OVH VPS Classic, this error was caused by a loop in /dev/shm and /run/shm. Both were symlinks linking to each other. So as root here is what I did:

    # rm /dev/shm
    # mkdir /dev/shm
    # chmod 777 /dev/shm
    # nano /etc/fstab
    

    Then I modified the shm line from:

    none /dev/shm tmpfs rw 0 0
    

    To:

    none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0
    

    Restarted the server... And that fixed the problem! Alternatively you can mount shm manually:

    # mount /dev/shm
    

    Hope this helps :-)

    0 讨论(0)
  • 2020-11-28 08:33

    One simple solution without rebooting is

    sudo chmod 777 /dev/shm
    

    That solved my problem.

    0 讨论(0)
提交回复
热议问题