[英]Ansible playbook stops working in new Ubuntu/Ansible/Python environment
[英]Ansible playbook, set environment variables not working
我必須將psycopg安裝到舊的python(2.4)。 除了設置環境變量-> LD_LIBRARY_PATH外,其他所有方法都工作正常。
- name: install psycopg
shell: "{{ item }}"
environment:
CPPFLAGS: "-I/my_python/lib/python2.4/site-packages/mx/DateTime/mxDateTime"
LD_LIBRARY_PATH: "/path_to_postgresql/lib"
args:
chdir: "/path_to_psycopg_src/"
with_items:
- ./configure --prefix=/my_python --with-python=/my_python/bin/python --with-postgres-libraries=/path_to_postgresql/lib --with-postgres-includes=/path_postgresql/include --with-mxdatetime-includes=/my_python/lib/python2.4/site-packages/mx/DateTime/mxDateTime
- make
- make install
成功安裝后,出現以下錯誤:
>>> import psycopg
ImportError: libpq.so.4: cannot open shared object file: No such file or directory
當我手動導出它時,它可以正常工作:
export LD_LIBRARY_PATH="/path_postgresql/lib"
>>> import psycopg
>>> psycopg
<module 'psycopg' from '/my_python/lib/python2.4/site-packages/psycopgmodule.so'>
因為您僅為install psycopg
任務設置了LD_LIBRARY_PATH
。 如果您不僅要為任務/劇本設置環境變量,我想您需要編輯/etc/environment
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.