Skip to content Skip to sidebar Skip to footer

Python Import Site Failed

When I execute python script, this problem occurs: 'import site' failed; use -v for traceback so I tried again with -v option, and I can get these messages: 'import site' failed;

Solution 1:

Looks like it expects a user with id 65530 to exist on your system, but it doesn't. And it gets that id by calling os.getuid() which returns the current user id.

Perhaps the user you're running this as has been deleted or disabled in the meantime? Check /etc/passwd for clues.


Update in light of your comment: apparently /etc/passwd does not exist inside your chroot jail. Either you can try mapping it in, or you can set the HOME environment variable to something sensible, as the code for expanduser says:

if'HOME'notinos.environ:
        import pwd
        userhome = pwd.getpwuid(os.getuid()).pw_dir
    else:
        userhome = os.environ['HOME']

Solution 2:

I too faced this issue. Little bit searching on the net, i got the fix. Check your environment variable PYTHONHOME.

Try to unset the PYTHONHOME and try. It worked for me.

(Ref: https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/532383)

Solution 3:

If you get this ERROR from mod_wsgi on apache (in you app error log), the FIX is to add "home=/path/to/app" to your WSGIDaemonProcess directive in your wsgi.conf (it doesn't matter that much where you set the path to). For example--

WSGIDaemonProcess ckan_default display-name=ckan_default processes=2 threads=15 home=/usr/lib/ckan/default

Post a Comment for "Python Import Site Failed"