Andrew Graham-Yooll
Andrew Graham-Yooll

Reputation: 2258

Running command line results in module not found as user postgres

Im trying to run a package wal-e which I have installed as user root with sudo python3 -m pip install wal-e[aws,azure,google,swift].

I can run this command perfectly as user root using envdir /etc/wal-e.d/env wal-e backup-fetch /var/lib/postgresql/9.6/main LATEST.

However, when I sudo su - postgres and then run envdir /etc/wal-e.d/env wal-e backup-fetch /var/lib/postgresql/9.6/main LATEST, I get the error

Traceback (most recent call last):
  File "/usr/local/bin/wal-e", line 7, in <module>
    from wal_e.cmd import main
ImportError: No module named 'wal_e.cmd'

I gave user postgres full sudo permissions with usermod -aG sudo postgres. Also the wal-e package is installed in the same location.

When I run ls -la I get

-rwxr-xr-x 1 root root 211 Sep 20 14:24 /usr/local/bin/wal-e

Im also on Ubuntu 16.04.3

How can I run the command just like the root user?

Upvotes: 2

Views: 339

Answers (1)

Andrew Graham-Yooll
Andrew Graham-Yooll

Reputation: 2258

I had to run a strict setup process for wal-e in order for the package to function properly.

Virtually what it boiled down to was installing all necessary dependencies on the machine that I was working with before installing and creating the user postgres. If the user was created before all the dependencies were installed, I got permissions errors.

Upvotes: 0

Related Questions