psycopg2-binary installation into a virtual environment fails when trying to compile source code - django

I am trying to install psycopg2-binary into my Django project. I am using a virtual environment and the command I'm running is
pip install psycopg2-binary
However, I'm getting a massive error message, the gist of it is this:
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.
But, hey, I'm installing exactly 'psycopg2-binary'
Why am I getting all this mess?

Pip cannot find you processor+OS at https://pypi.org/project/psycopg2-binary/2.9.2/#files so it tried to install from sources (the last file at the page) and failed.
Compiling from sources is currently the only way. If you can donate some spare processor cycles to the Psycopg2 authors they perhaps could start compiling and publishing wheels for OSX on M1.

Related

Error installing django-heroku Error: pg_config executable not found

I tried installing django-heroku via pip so I can deploy my project on heroku but during installation of django-heroku it tried to install psycopg2 along only to produce an error:
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'.
And I also wish to know if I'm required to pip install it since heroku installs the libaries specified in the requirements.txt file,if not required are there changes I need to make to my project before deployment.
Perhaps not optimal solution but it did work for me.
pip install --no-dependencies django-heroku
Be sure to have other required packages installed.
pip install django
pip install whitenoise
pip install psycopg2-binary
P.S. I have already had postgresql installed on my Mac. Not sure why I was getting the same error.
I renamed "psycopg2" in the python site packages folder to "psycopg2-binary", and this fixed my issue.

dlib is not installing in pythonanywhere virtualenv

I am trying to recognize faces in an image using "face_recognition" library,to use it we have to install dlib but when installing dlib in pythonanywhere virtualenv console it is throwing some errors
below is the error I got during installation of dlib
(env) 16:09 ~/dlib (master)$ python setup.py install --yes
USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA
running install
running bdist_egg
running egg_info
creating dlib.egg-info
writing dlib.egg-info/PKG-INFO
writing top-level names to dlib.egg-info/top_level.txt
writing dependency_links to dlib.egg-info/dependency_links.txt
writing manifest file 'dlib.egg-info/SOURCES.txt'
package init file 'dlib/__init__.py' not found (or not a regular file)
reading manifest file 'dlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'dlib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
error: [Errno 38] Function not implemented
It looks like there's some strange problem with the current version of dlib that's stopping it from installing on PythonAnywhere. Version 19.3.1 seems to work:
pip2.7 install --user dlib==19.3.1
pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f
Try installing from this cmd command, assuming that you have already added pip in path

Installing Python package from source into virtualenv directory

Newbie programmer here. This is a variation of this question and this question.
I am running Python 2.7 on Windows 7, and using git bash shell. I am trying to install the numpy package into a virtualenv directory in my work directory. I cannot install it using the $pip install -r requirements.txt or the $pip install numpy commands because of errors caused by its dependencies. Here is a log file for this install failure.
Although I can install numpy directly by downloading the executable binary (.exe) from sourceforge, but it forced me to install it in the c:/Python27/Lib/site-packages directory. I need to install it in my virtualenv work directory, e.g. c:/Users/MyName/Projects/myproject/myvirtualenv.
I need help on how to download the necessary numpy files into a temp directory, and how to use pip or another tool install it into my virtualenv directory.
I researched that I can choose a target directory using the -t option in pip, e.g., "pip install numpy --target=c:/Users/MyName/Projects/myproject/myvirtualenv". But I still can't get over the dependencies errors, so pip doesn't work for me unless I can figure out how to download the numpy files (including all dependencies) into a directory and then install from there.
Thanks for your help!

Install psycopg2 on Synology

I try to install psycopg2 on my DS2413+ (DSM 4.3). I've installed Python 2.7 with ipkg and pip. When I do :
/opt/local/bin/pip2.7 install psycopg2
I got the following 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'.
Complete output from command python setup.py egg_info:
running egg_info
But I didn't found pg_config in my /usr/syno/ where a built in version of pgsql is already installed.
In other topics with this kind of error, they recommend to install python-dev, but I can't manage to install it on my NAS ... There is also a py26-psycopg2 ikpg but I need to install it on Python 2.7.
If anyone has a solution to these problem please tell me :')
Cheers
You don't need to install psycopg2, it is already installed in the site-packages if you used the official Synology python package, see
/usr/local/packages/#appstore/Python/usr/local/lib/python2.7/site-packages/
Also, using pip from ipkg may mess up your python install as there should really be one python2.7 installation.

pip install: How to force a specific package version

I'm trying to install Django 1.4.3, but when I execute pip install, pip keeps installing Django 1.5 version instead 1.4.3
sudo pip install -I Django==1.4.3
It returns:
Downloading/unpacking Django==1.4.3
Running setup.py egg_info for package Django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
=== >>>> Requested Django==1.4.3, but installing version 1.5 <<<< ====
Installing collected packages: Django
Found existing installation: Django 1.5
Uninstalling Django:
Successfully uninstalled Django
Running setup.py install for Django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
changing mode of /usr/local/bin/django-admin.py to 755
Successfully installed Django
Cleaning up...
but if I execute pip freeze, it keeps showing
Django==1.5
What am I doing wrong?
Thank you
This could/should/can be helped by clearing the build dir for Django in pip.
There is a bug for this, since version 1.1 see here for details
You can start checking for these folders here if you're on OS X or unix like systems:
~/.pip
/tmp/pip-build-root (or pip-build-$USER, if you aren't running pip as root).
This is if you haven't specified a new build folder when you installed the first version of Django.
Good luck!
As limelight says, you should empty your cache and build directories, or pass in a temporary clean location with the --download-cache and flag.
$ pip help install
[...]
--download-cache <dir> Cache downloaded packages in <dir>.
-b, --build <dir> Directory to unpack packages into and build in. The default in a virtualenv is "<venv path>/build". The default for global installs is
"<OS temp dir>/pip-build-<username>".
I'd like to warn any readers to not use sudo pip install to install Django. It installs Django system-wide. And changing the system-wide version could break system-packages that depend on it. For instance, Ubuntu MAAS and Cobbler depend on the system django package. These are typically services you don't want to break.
If you need a different version than the system-package, use virtualenv to isolate your dependencies from the system.
OP seems to be on OSX and I don't know of any server-wide Mac Django, but that may change. Consider installing python packages with sudo at par to changing the system-installed python with python 3; it might work for now, but have some paracetamol in stock, as you're in for some headaches.
Check your local cache and remove it can be help. I hava installed pymongo==2.5.2. To install pymongo==2.4.1, I remove the cache in /tmp/pip-build-root/pymongo.Then I install pymongo 2.4.1 successfully.