Cpanel can't install psycopg2 - python

Been trying to install psycopg2 on a client's Cpanel but every time I try, I get the following message:
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
[end of output]
As far as I've seen, for production, you shouldn't use psycopg2-binary, but then psycopg2 doesn't give me many options.
The Cpanel has PostgreSQL installed, and it even has phpPgAdmin. I tried seeing a lot of videos and questions done here on this platform but haven't found anything.
Any solution to this?

Related

Cant get Streamlit and Postgresql to work together properly. Error with psycopg2

After I enter all the private details into streamlit to connect to the Postgresql database, I cant seem to figure out how to get the Package Psycopg2 to import correctly on the Streamlit cloud.
When Streamlit tries to download the Psycopg2 package, the following error arises:
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
/home/appuser/venv/lib/python3.9/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
warnings.warn(msg, warning_class)
running egg_info
creating /tmp/pip-pip-egg-info-b4u4zbek/psycopg2.egg-info
writing /tmp/pip-pip-egg-info-b4u4zbek/psycopg2.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-b4u4zbek/psycopg2.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-pip-egg-info-b4u4zbek/psycopg2.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-b4u4zbek/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
[end of output]
My problem is that I don't know how to add pg_config to the PATH. Here is my github: https://github.com/zuhorski/My-UFC-Project
Also for what its worth, I'm working in a virtual environment and I did find where this pg_config file is located: "C:\Program Files\PostgreSQL\15\bin"

Installation of psycopg2 on Ubuntu 14.10

Complete newbie here, trying to set up Django to work with PostgreSQL.
I am using Ubuntu 14.10 and I have also installed PostgreSQL 9.5.
When I run pip install psycopg2 in terminal I get the following error:
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-la8dJp/psycopg2
I know that directory containing pg_config is /opt/PostgreSQL/9.5/bin/pg_config but I don't know how to add this directory to PATH to get my psycopg2 installed. Or any another method to get psycopg2 installed so that I can interact with my PostgreSQL.
Thanking you in advance.
Unless you do have a hard requirement on using the native postgresql library, I would advise you to use the pg8000 library instead because this one is pure python.
Since I discovered it years ago, I stopped using the other one and forgot about the having to compile it on so many platforms.

Can't figure out where Heroku app is failing [Error: pg_config executable not found.]

Hoping you can help me figure this one out. I'm slogging through the Heroku 'Getting Started with Python' page where you install the necessary dependencies to run an app locally. It all works well up until the 2nd to last step, running the command virtualenv venv. I run that, then the next command, pip install -r requirements.txt --allow-all-external, and that's where I get this error:
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_nickcode/psycopg2
Storing debug log for failure in /tmp/tmpb5tCeK
I don't understand why I'm getting this error. Can anyone help me make sense of it?
My version of requirements.txt:
dj-database-url==0.3.0
Django==1.8.1
django-postgrespool==0.3.0
gunicorn==19.3.0
psycopg2==2.6
SQLAlchemy==1.0.4
whitenoise==1.0.6
pg_config is part of postgresql ( http://www.postgresql.org/docs/8.1/static/app-pgconfig.html ).
So you need to install postgresql.
brew install postgresql
resolves this issue on macOS
I have overcame this issue defining a environment variable HEROKU and putting the following lines at the end of settings.py
if config('HEROKU', cast=bool, default=False):
import django_heroku
django_heroku.settings(locals())
As Heroku use the buildpack: heroku/python, there is no additional configuration to perform

Getting Started with Python on Heroku - pg_config executable not found

I have been following the documentation until I got to the point of installing the requirements.txt file. It always fails when trying to install line 6 "psycopg2==2.5.3". Here is the message -
Downloading/unpacking psycopg2==2.5.3 (from -r requirements.txt (line 6))
Downloading psycopg2-2.5.3.tar.gz (690kB): 690kB downloaded
Running setup.py (path:/Users/pimpc/Sites/python/herokudemo/python-getting-started/venv/build/psycopg2/setup.py) egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to
pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to
pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Of course I found several posts on this. So I started checking things. I believe that postgres app for mac comes with psycopg2. I do have postgres added to my path and checked in terminal running "echo $PATH". I do not have any other old versions conflicting. And postgres documentation says I should have it added to my path like this -
export PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH:$PATH"
I have restarted postgres app, deactivated and restarted virtual env and I get the same error no matter what.
What could I possibly be overlooking! I have read and read other posts on here, and even blogs covering this issue.
After reading dozens of the same errors people were all having with the postgres mac app. I decided to install postgres via brew and now it all works just fine.

Psycopg2 on Amazon Elastic Beanstalk

I'm trying upload my project (in python) that uses Psycopg2 for Amazon Elastic Beanstalk. I'm doing this with a zip file containing my project and an requirements.txt file.
But I'm receiving this error:
Downloading/unpacking psycopg2>=2.4.6 (from -r
/opt/python/ondeck/app/requirements.txt (line 3)) Running setup.py
egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
How can I solve this on Amazon?
Need postgresql-devel in your container.
Create a file '.ebextensions/packages.config' with the contents:
packages:
yum:
postgresql94-devel: []
Replace 94 in postgresql94-devel with whatever version of postgres you need. For example, postgresql93-devel for postgres 9.3.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages
Tried to comment on the accepted answer but don't have the reputation to do so. Recent forum posts from AWS support indicate that the package name is "postgresql93-devel". postgresql-devel does not work in the 2014.09 AMIs.
I struggled for a while with and couldn't get the above solution to work. I tried many other solutions as well, but it ended up being a lack of fundamental understanding on my part.
The config files are read alphabetically. So if you have more than one, which you likely do, make sure that 'packages.config' comes alphabetically before your .config with container_commands.
Otherwise 'syncdb' for example will be called before your packages have been installed.
sudo yum install gcc python-setuptools python-devel postgresql-devel
sudo easy_install psycopg2
This worked perfectly on my Linux AWS

Categories