简体   繁体   English

如何为python脚本导入LD_LIBRARY_PATH? 无root权限。 无权重启apache服务器

[英]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托管服务中有一个共享主机。它有以下限制。

  • No root access 无root权限
  • No permission to restart apache server 无权重启apache服务器

My hosting service system and applications specifications. 我的托管服务系统和应用程序规范。

  • Postgres 10.7 Postgres 10.7
  • python3 python3
  • OS -- Linux version 2.6.32-896.16.1.lve1.4.54.el6.x86_64 (mockbuild@buildfarm03.cloudlinux.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) OS - Linux版本2.6.32-896.16.1.lve1.4.54.el6.x86_64(mockbuild@buildfarm03.cloudlinux.com)(gcc版本4.4.7 20120313(Red Hat 4.4.7-18)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM