1

I am having trouble installing the package psycopg2 through ebextensions.

00_software.config

packages:
  yum:
    git: []
    htop: []
  pip:
    psycopg2: []

01_setup_pg_activity.config

commands:
    clone:
        command: git clone https://github.com/dalibo/pg_activity.git
    install_psycopg2:
        command: cd pg_activity && python setup.py install

Alternatively, I have also tried this to no avail

commands:
    clone:
        command: git clone https://github.com/dalibo/pg_activity.git
    install_psycopg2:
        command: pip install psycopg2
    install_psycopg2:
        command: cd pg_activity && python setup.py install

The other software installs but pip packages will not

Traceback (most recent call last):
  File "/usr/local/bin/pg_activity", line 4, in <module>
    __import__('pkg_resources').run_script('pg-activity==1.6.1', 'pg_activity')
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 742, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1510, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/site-packages/pg_activity-1.6.1-py2.7.egg/EGG-INFO/scripts/pg_activity", line 42, in <module>

ImportError: No module named psycopg2

I have to manually go in and run sudo pip install psycopg2 for it to correctly install. How can I do this in the build process?

ikonuk
  • 575
  • 8
  • 19
NooBskie
  • 3,761
  • 31
  • 51
  • Is it amazon linux 1 or 2? Also I assume its python env? – Marcin May 27 '20 at 05:46
  • 2 I'm pretty sure. the beanstalk environment is RoR but I have all the essential things needed for python installed on it already – NooBskie May 27 '20 at 06:20
  • If you are using a virtual environment and EB CLI, simply creating `requirements.txt` will be enough while the virtual environment is active. EB CLI handles the package installations on deployment. – ikonuk Jun 01 '20 at 19:27
  • @ikonuk thanks this is the only thing that worked for me if you want to post as an answer ill accept – NooBskie Jun 02 '20 at 23:33

2 Answers2

1

Using EB with AL2 (python env; haven't tested on RoR), successfully installed pg_activity.

For packages (only psycopg2 shown) I had

packages: 
    yum:
        python-psycopg2: []

And the commands config file was (20_setup_pg_activity.config):

commands:
    05_clone:
        command: git clone https://github.com/dalibo/pg_activity.git    
    10_install_pg_activity:
        command: cd pg_activity && python setup.py install

Following the env setup, I logged into the EB instance to check if pg_activity exists (only part shown):

ec2-user@ip-172-31-82-127 ~]$ pg_activity --help
Usage: pg_activity [options]

htop like application for PostgreSQL server activity monitoring.

Options:
  --version             show program's version number and exit
  -U USERNAME, --username=USERNAME
Marcin
  • 215,873
  • 14
  • 235
  • 294
1

If you are using a virtual environment and EB CLI, simply creating requirements.txt will be enough while the virtual environment is active. EB CLI handles the package installations on deployment.

ikonuk
  • 575
  • 8
  • 19