[英]Running Python in mod_wsgi in Apache Cannot See Python Modules in /usr/local/lib64/python3.6/site-packages
I have had scores of servers running a Python script via Apache and mod_wsgi for years now.多年来,我有很多服务器通过 Apache 和 mod_wsgi 运行 Python 脚本。 I recently am building on RHEL7 and have run into an issue where my Python script calling R procedures are bombing out only via Apache stating it cannot find my pip installed Python modules in my Apache log. I recently am building on RHEL7 and have run into an issue where my Python script calling R procedures are bombing out only via Apache stating it cannot find my pip installed Python modules in my Apache log.
import pandas as pd ModuleNotFoundError: No module named 'pandas'将 pandas 导入为 pd ModuleNotFoundError:没有名为“pandas”的模块
This seems to only affect modules getting installed in /usr/local/lib64/python3.6/site-packages which is where my custom modules are being installed with pip.这似乎只影响安装在 /usr/local/lib64/python3.6/site-packages 中的模块,这是我的自定义模块与 pip 一起安装的位置。
Even if I append it, it ignores it.即使我 append 它,它也会忽略它。
sys.path.append(r'/usr/local/lib64/python3.6/site-packages') sys.path.append(r'/usr/local/lib64/python3.6/site-packages')
I manually built mod_wsgi from source.我从源代码手动构建了 mod_wsgi。
I'm ready to abandon mod_wsgi because I have to get my application deployed for my users.我准备放弃 mod_wsgi 因为我必须为我的用户部署我的应用程序。
Any help is greatly appreciated.任何帮助是极大的赞赏。
Thanks,谢谢,
Lou娄
It was a file priv issue with /usr/lib64/python3.6 and /usr/lib/python3.6 directories and their child directories.这是 /usr/lib64/python3.6 和 /usr/lib/python3.6 目录及其子目录的文件权限问题。 Root ran fine, but running as Apache had no access. Root 运行良好,但以 Apache 的身份运行无法访问。 You had to chmod-R 755 on both directory trees.您必须在两个目录树上 chmod-R 755。 Worked fine with Apache after that.之后与 Apache 一起工作正常。 Sometimes it's the simple things we forget to check first.有时这是我们忘记先检查的简单事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.