Python( Django ) pip install psycopg2 error in MacOS - python

I set the virtualenv for my project and when I want to run
pip install psycopg2
I get an error below
ERROR: Complete output from command python setup.py egg_info:
ERROR: running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from the 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
<http://initd.org/psycopg/docs/install.html>).
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/r5/mt37g42j2h3b676lpx3qlznm0000gn/T/pip-install-yijundiy/psycopg2/
after that, I run brew install postgresql and then when I wanted to run :
pip install psycopg2 I got this error:
Running setup.py install for psycopg2 ... error
Running setup.py install for psycopg2 ... error
ERROR: Complete output from command
ERROR: Command "/Users/masoudmk/Desktop/Masoud/projectenv/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/tmp/pip-install-6qi9xbe0/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-t8hmiffn/install-record.txt --single-version-externally-managed --compile --install-headers /Users/masoudmk/Desktop/Masoud/projectenv/bin/../include/site/python3.7/psycopg2" failed with error code 1 in /private/tmp/pip-install-6qi9xbe0/psycopg2/
In addition, when I use this command
sudo python setup.py install
I get this error too:
(null): can't open file 'setup.py': [Errno 2] No such file or directory
What should I do!?

get a stand-alone package
run pip install psycopg2-binary

I think you don't have Postgres installed, you can install by using
brew install postgresql
that helps your problem. after that, you can install pip dependency packages

Related

How to install psycopg2 on Python 3.9 on Windows?

I have been trying to install psycopg2 (pip install psycopg2), but I keep getting this error.
I have also tried with: pip install psycopg2-binary but I'm getting the same error.
Here is the error message:
ERROR: Command errored out with exit status 1:
command: 'c:\users\viktor\pycharmprojects\wemport\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycop
g2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'
"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl'
cwd: C:\Users\Viktor\AppData\Local\Temp\pip-install-015ceiei\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info
writing C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\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>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How to fix that?
The following will install prebuilt binaries for windows. It's worked for me on 3.9. You can uninstall pipwin after install psycopg2.
pip install pipwin
pipwin install psycopg2
Optional after psycopg2 installed:
pip uninstall pipwin
if u use linux
You need to make sure that you install wheel model
and Try that
sudo ./venv/bin/python -m pip install wheel
after that install psycopg2 and psycopg2-binary
sudo ./venv/bin/python -m pip install psycopg2
sudo ./venv/bin/python -m pip install psycopg-binary

Trouble installing django-heroku

I am trying to deploy my django application to heroku.
When I try to pip install django-heroku, it gives me this error:
ERROR: Command errored out with exit status 1:
command: /Users/huntermackenzie/Dev/personal/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/pip-egg-info
cwd: /private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/
Complete output (23 lines):
running egg_info
creating /private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/pip-egg-info/psycopg2.egg-info
writing /private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/15/k9lcjv5129v661mkkrsdt09w0000gn/T/pip-install-v2fvrgwp/psycopg2/pip-egg-info/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>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Trying to pip install psycopg2 gives me the same error.
Can someone please help me. Thank you.
The error message suggests
pip install psycopg2-binary
have you tried it?

Install Odoo from sourcce: Error: pg_config executable not found

I am using source code https://github.com/odoo/odoo/tree/aa0554d224337e1d966479a351a3ed059d297765
on Windows 10, Python version
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
I catch error
ERROR: Command errored out with exit status 1:
command: 'c:\program files (x86)\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\xxxxxxxx\\AppData\\Local\\Temp\\pip-install-e5g8ghcb\\psycopg2\\setup.py'"'"'; __file__='"'"'C:\\Users\\xxxxxxxx\\AppData\\Local\\Temp\\pip-install-e5g8ghcb\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\pip-egg-info'
cwd: C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\pip-egg-info\psycopg2.egg-info
writing C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\pip-egg-info\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\pip-egg-info\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\pip-egg-info\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\xxxxxxxx\AppData\Local\Temp\pip-install-e5g8ghcb\psycopg2\pip-egg-info\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
<http://initd.org/psycopg/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How to fix it?
From Windows Source Install
Warning
Some dependencies cannot be installed through pip and require to be installed manually.
In particular:psycopg must be installed with
this installer.wkhtmltopdf must be installed in version 0.12.5
for it to support headers and footers. See our
wiki for more details on the
various versions.
As the error message suggest to you:
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
The psycopg2 package for Python 3.8 is released and you can
install it with pip:
pip install psycopg2
If you want to install psycopg2 from source, refer to the official
docs.

ERROR: Command errored out with exit status 1:

i am installing connector of Psycopg2 but i am unable install, how do i install that successfully?
in using this command line to install:
pip install psycopg2
(test) C:\Users\Shree.Shree-PC\Desktop\projects\purchasepo>pip install psycopg2
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar
.gz
ERROR: Command errored out with exit status 1:
command: 'c:\users\shree.shree-pc\envs\test\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Shr
ee.Shree-PC\\AppData\\Local\\Temp\\pip-install-_bgz1zs9\\psycopg2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Shree.Shree-PC\\AppData\\Local\\T
emp\\pip-install-_bgz1zs9\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-
install-_bgz1zs9\psycopg2\pip-egg-info'
cwd: C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-install-_bgz1zs9\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-install-_bgz1zs9\psycopg2\pip-egg-info\psycopg2.egg-info
writing C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-install-_bgz1zs9\psycopg2\pip-egg-info\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-install-_bgz1zs9\psycopg2\pip-egg-info\psycopg2.egg-info\depe
ndency_links.txt
writing top-level names to C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-install-_bgz1zs9\psycopg2\pip-egg-info\psycopg2.egg-info\top_l
evel.txt
writing manifest file 'C:\Users\Shree.Shree-PC\AppData\Local\Temp\pip-install-_bgz1zs9\psycopg2\pip-egg-info\psycopg2.egg-info\SOURCES.t
xt'
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
<http://initd.org/psycopg/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
command line is correct
path should be checked and perhaps psycopg2 needs a visual C ++ build tools update from https://visualstudio.microsoft.com/visual-cpp-build-tools/
I had this problem when I installed python 3.10.0
if you are using python 3.10:
currently psycopg doesn't support python 3.10
The current psycopg2 implementation supports:
1.Python versions from 3.6 to 3.9
2.PostgreSQL server versions from 7.4 to 13
3.PostgreSQL client library version from 9.1
source : https://www.psycopg.org/docs/install.html
and if you're using windows with any version of python but 3.10 please try install psycopg2 by running :
pip install psycopg2-binary

python command pip install pillow in windows getting error

building 'PIL._imaging' extension
error: [WinError 2] The system cannot find the file specified
----------------------------------------
Failed building wheel for Pillow
Failed to build Pillow
Installing collected packages: Pillow
Running setup.py install for Pillow
Complete output from command c:\users\anilkumar.vandrangi\desktop\aspire\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\ANILKU~1.VAN\\AppData\\Local\\Temp\\pip-build-tr4denzb\\Pil
low\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ANILKU~1.VAN\AppData\Local\Temp\pip-7zffvlgz-record\in
stall-record.txt --single-version-externally-managed --compile:
Single threaded build, not installing mp_compile: 4 processes
running install
running build
running build_py
running egg_info
writing top-level names to Pillow.egg-info\top_level.txt
writing Pillow.egg-info\PKG-INFO
writing dependency_links to Pillow.egg-info\dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'Pillow.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'Pillow.egg-info\SOURCES.txt'
running build_ext
building 'PIL._imaging' extension
error: [WinError 2] The system cannot find the file specified
----------------------------------------
Command "c:\users\anilkumar.vandrangi\desktop\aspire\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\ANILKU~1.VAN\\AppData\\Local\\Temp\\pip-build-tr4denzb\\Pillow\\setup.py';exec(comp
ile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\ANILKU~1.VAN\AppData\Local\Temp\pip-7zffvlgz-record\install-record.txt --singl
e-version-externally-managed --compile" failed with error code 1 in C:\Users\ANILKU~1.VAN\AppData\Local\Temp\pip-build-tr4denzb\Pillow
I'm assuming that you have are on x64 bit Windows.
The cleanes way to solve it:
If you have installed 32 bit version of python: uninstall it
install 64 bit
During setup choose to add python to path
Download 64 bit version of pillow:
http://wp.stolaf.edu/it/installing-pil-pillow-cimage-on-windows-and-mac/
Run the setup file.
Check your Pip version to see if you have the last version available.
C:\ python3 -m pip install --version
You can either use python or python3, I used python3 because I have 2.7 and 3.5 on the same disk.
If your version is not the latest update with:
C:\ python3 -m pip install --upgrade pip
Then now try pip install Pillow again:
C:\ python3 -m pip install Pillow
This time it has to work without problems.
You're getting this error because the pillow version you're trying to install is incompatible with your python version.
Try upgrading both as a final resort.

Categories

Resources