Why can't python find some modules when I'm running CGI scripts from the web?

后端 未结 3 941
梦谈多话
梦谈多话 2020-11-30 13:49

I have no idea what could be the problem here:

I have some modules from Biopython which I can import easily when using the interactive prompt or executing python scr

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 14:32

    Here are a couple of possibilities:

    • Apache (on Unix) generally runs as a different user, and with a different environment, to python from the command line. Try making a small script that just prints out sys.version and sys.prefix, and compare the result through apache and via the command line, to make sure that you're running from the same installation of python in both environments.
    • Is Biopython installed under your home directory, or only readable just for your normal user? Again, because apache generally runs as a different user, perhaps you don't have access to that location, so can't import it.
    • Can you try doing import site before trying to import Biopython? Perhaps something is preventing site packages from being imported when you run through apache.

提交回复
热议问题