[英]How to import LD_LIBRARY_PATH for python script? No root access. No permission to restart apache server
I have a shared hosting in GoDaddy hosting service.It has the following limitations. 我在GoDaddy托管服务中有一个共享主机。它有以下限制。
My hosting service system and applications specifications. 我的托管服务系统和应用程序规范。
I use a cgi script to redirect the apache server to my Python script. 我使用cgi脚本将apache服务器重定向到我的Python脚本。 When Python tries to import the psycopg2 module, the following error is thrown 当Python尝试导入psycopg2模块时,会引发以下错误
/home/user/python_base/lib/python3.4/site-packages/psycopg2/_psycopg.cpython-34m.so: undefined symbol: PQescapeIdentifier
I exported the postgresql/lib
path to LD_LIBRARY_PATH
and restarted the Python script locally and it works fine. 我将postgresql/lib
路径导出到LD_LIBRARY_PATH
并在本地重新启动Python脚本,它运行良好。
But since I cannot restart the apache server, I guess the process in which the apache is running does not have the LD_LIBRARY_PATH
updated. 但是由于我无法重新启动apache服务器,因此我猜测运行apache的进程没有更新LD_LIBRARY_PATH
。 So the error persists. 所以错误仍然存在。 I have a python environment running. 我有一个python环境正在运行。 I copied all the library files from postgresql/lib
to mypythonenv/lib
, still in vain. 我将所有库文件从postgresql/lib
复制到了mypythonenv/lib
,仍然徒劳。
您可以在导入psycopg2 之前在os.environ
设置环境变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.