Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

419
Views
¿Se puede usar python venv con plpython3u para postgresql?

Me gustaría que plpython3u use un entorno virtual para python. He visto algunas instrucciones (antiguas y no particularmente claras) para virtualenv en PostgreSQL PL/Python: llame al procedimiento almacenado en virtualenv . Sin embargo, no he visto nada para python venv. ¿Se puede hacer esto y, de ser así, cómo se puede hacer? Gracias.

CCl.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si solo necesita un entorno venv para PL/Python, simplemente puede modificar ExecStart en el archivo de la unidad PostggreSQL para cargar el script de activate venv .

A continuación, se extrae del archivo de unidad systemd de PostgreSQL 14 de la instalación de PGDG YUM (My venv ls ubicado en /var/lib/pgsql/plpython/ ).

 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} #ExecStart=/usr/pgsql-14/bin/postmaster -D ${PGDATA} ExecStart=/bin/bash -c "source /var/lib/pgsql/plpython/bin/activate && /usr/pgsql-14/bin/postmaster -D ${PGDATA}"

Tenga en cuenta que debe copiar el archivo de unidad postgresql-14.service de /usr/lib/systemd/system/ a /etc/systemd/system/ y ejecutar systemctl daemon-reload para que surta efecto.

Luego puede verificar venv con el módulo pkg_resources dentro del bloque anónimo PL/Python (instalo pyyaml en mi entorno venv ).

 postgres=# CREATE EXTENSION plpython3u ; CREATE EXTENSION postgres=# DO $$ import pkg_resources installed_packages = pkg_resources.working_set installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages]) plpy.notice(installed_packages_list) $$ LANGUAGE plpython3u; NOTICE: ['pip==9.0.3', 'pyyaml==5.4.1', 'setuptools==39.2.0'] DO postgres=#
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!