Package requirement 'psycopg2==2.9.1' not satisfied pycharm macos - python

after long hours of trying: i installed psycopg2==2.9.1 with pip
installed with pip
I tried adding it to all the interpreter paths i could find but still keep getting this message:
error message
I tried as well restarting pycharm, invalidate caches ..
When trying to just install it with pycharm i get this error messege:
Collecting psycopg2==2.9.1
Using cached psycopg2-2.9.1.tar.gz (379 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py): started
Building wheel for psycopg2 (setup.py): finished with status 'error'
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2: started
Running setup.py install for psycopg2: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: '/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/bin/python' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/setup.py'"'"'; __file__='"'"'/private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-wheel-lbvr1lzp
cwd: /private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/
Complete output (53 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.13.0-x86_64-3.9
creating build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/_json.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/extras.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/errorcodes.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/tz.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/_range.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/_ipaddress.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/__init__.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/extensions.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/errors.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/sql.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/pool.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.macosx-10.13.0-x86_64-3.9
creating build/temp.macosx-10.13.0-x86_64-3.9/psycopg
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/MISSING/DEPS//stage/include -I/MISSING/DEPS//stage/unixodbc/include -I/MISSING/DEPS//stage/include -I/MISSING/DEPS//stage/unixodbc/include -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140001 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/include -I/Applications/QGIS.app/Contents/MacOS/include/python3.9 -I. -I/opt/homebrew/include -I/opt/homebrew/include/postgresql/server -I/opt/homebrew/Cellar/icu4c/69.1/include -I/opt/homebrew/opt/openssl#1.1/include -I/opt/homebrew/opt/readline/include -c psycopg/adapter_asis.c -o build/temp.macosx-10.13.0-x86_64-3.9/psycopg/adapter_asis.o
In file included from psycopg/adapter_asis.c:28:
./psycopg/psycopg.h:35:10: error: 'Python.h' file not found with <angled> include; use "quotes" instead
#include <Python.h>
^~~~~~~~~~
"Python.h"
./psycopg/psycopg.h:35:10: warning: non-portable path to file '<python.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include <Python.h>
^~~~~~~~~~
<python.h>
In file included from psycopg/adapter_asis.c:28:
In file included from ./psycopg/psycopg.h:35:
psycopg/Python.h:31:2: error: "psycopg requires Python 3.6"
#error "psycopg requires Python 3.6"
^
psycopg/Python.h:34:10: fatal error: 'structmember.h' file not found
#include <structmember.h>
^~~~~~~~~~~~~~~~
1 warning and 3 errors generated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for psycopg2
ERROR: Command errored out with exit status 1:
command: '/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/bin/python' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/setup.py'"'"'; __file__='"'"'/private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-record-fkjtibr5/install-record.txt --single-version-externally-managed --compile --install-headers '/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/include/site/python3.9/psycopg2'
cwd: /private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/
Complete output (55 lines):
running install
/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.macosx-10.13.0-x86_64-3.9
creating build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/_json.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/extras.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/errorcodes.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/tz.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/_range.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/_ipaddress.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/__init__.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/extensions.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/errors.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/sql.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
copying lib/pool.py -> build/lib.macosx-10.13.0-x86_64-3.9/psycopg2
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.macosx-10.13.0-x86_64-3.9
creating build/temp.macosx-10.13.0-x86_64-3.9/psycopg
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/MISSING/DEPS//stage/include -I/MISSING/DEPS//stage/unixodbc/include -I/MISSING/DEPS//stage/include -I/MISSING/DEPS//stage/unixodbc/include -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=140001 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/include -I/Applications/QGIS.app/Contents/MacOS/include/python3.9 -I. -I/opt/homebrew/include -I/opt/homebrew/include/postgresql/server -I/opt/homebrew/Cellar/icu4c/69.1/include -I/opt/homebrew/opt/openssl#1.1/include -I/opt/homebrew/opt/readline/include -c psycopg/adapter_asis.c -o build/temp.macosx-10.13.0-x86_64-3.9/psycopg/adapter_asis.o
In file included from psycopg/adapter_asis.c:28:
./psycopg/psycopg.h:35:10: error: 'Python.h' file not found with <angled> include; use "quotes" instead
#include <Python.h>
^~~~~~~~~~
"Python.h"
./psycopg/psycopg.h:35:10: warning: non-portable path to file '<python.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include <Python.h>
^~~~~~~~~~
<python.h>
In file included from psycopg/adapter_asis.c:28:
In file included from ./psycopg/psycopg.h:35:
psycopg/Python.h:31:2: error: "psycopg requires Python 3.6"
#error "psycopg requires Python 3.6"
^
psycopg/Python.h:34:10: fatal error: 'structmember.h' file not found
#include <structmember.h>
^~~~~~~~~~~~~~~~
1 warning and 3 errors generated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: '/Users//Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/bin/python' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/setup.py'"'"'; __file__='"'"'/private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-install-myo1zngt/psycopg2_e9a9698f63464cb99bc5bf3655675aa2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/fj/blrljwxs22q3csr4fqw7ycmc0000gn/T/pip-record-fkjtibr5/install-record.txt --single-version-externally-managed --compile --install-headers '/Users/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/data_index-development/venv/include/site/python3.9/psycopg2' Check the logs for full command output.
What can fix it?

You're trying to build the psycopg package from source. That requires development files for Python, such as Python.h, which usually don't come automatically on macOS.
Instead, try the suggestion in the error message: install psycopg_binary:
pip install psycopg2-binary
The installed package will just be psycopg2, but there is no need to compile it from source.

Usually had something similar happen to me while using anaconda, and I had to manually delete the folder location and reinstall to be importable (even with new enviroment).
I would suggest you try anaconda, miniconda with the same requirements and see if those help you out with your environment problem. Note: This requires separate installation. Follow some of the creation guides but in general the essence would be something like:
conda create --name testenv python=3.8
conda activate testenv
conda install psycopg2"==2.9.1" -c conda-forge
After doing the last command in terminal, you are going to get something like this (just different version, but added into the command for 2.9.1):
You generally can search on anaconda website if you aren't familiar with the channels and the commands.
To check if everything is alright in the environment itself:
Now try to use this environment in PyCharm (by changing the base interpreter to the testenv one), if you still have problems do include the error message.
This also separates the issue from PyCharm or Pip wheel, and see if you can run get a running environment.

Related

gcc error while installing psycopg2 on RHEL 7 VM

My environment in RHEL 7, Python 3.6 and Postgres is located on RDS cluster.
I am using Pycharm to develop. I did
python -m pip install psycopg2 it gives error
command gcc failed with exit status 1
To rectify, I tried to install psycopg2-binary but I need psycopg2 package to connect to postgres through python script. If I use SQLAlchemy, it directs through the psycopg2 package.
I tried sudo yum install postgresql-libs .... sudo yum install postgresql-devel but the problem persists.
Here's the full error in a picture:
Full error:
[priya#localhost psycopg2-2.9.1]$ pip install psycopg2
Defaulting to user installation because normal site-packages is not writeable
Collecting psycopg2
Using cached psycopg2-2.9.1.tar.gz (379 kB)
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2rdr62wb/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/priya/.local/include/python3.6m/psycopg2
cwd: /tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/
Complete output (38 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/psycopg
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=90224 -DPSYCOPG_DEBUG=1 -I/usr/include/python3.6m -I. -I/usr/include -I/usr/include/pgsql/server -I/usr/include/libxml2 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:0:
./psycopg/psycopg.h:35:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oe9qfnfj/psycopg2_0348a9316a144cb3bcfec63fc1fb2743/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-2rdr62wb/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/priya/.local/include/python3.6m/psycopg2 Check the logs for full command output.
Solution:
sudo yum repo-pkgs rhel-7-server-optional-rpms list | grep python3
sudo yum install python3-devel.x86_64 --enablerepo=rhel-7-server-optional-rpms
pip install psycopg2
Courtesy: Jonathan's answer from How to install python3-devel on red hat 7

Getting error while installing mysqlclient on Mac

I am trying to install mysqlclient on macOS BigSur(running on M1 chip mac) as a part of implementing django project using MySQL DB. However, I am getting below error:
Collecting mysqlclient
Using cached mysqlclient-2.0.3.tar.gz (88 kB)
Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/setup.py'"'"'; __file__='"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/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/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-record-jl3d35rj/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/mysqlclient
cwd: /private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/
Complete output (41 lines):
mysql_config --version
['8.0.22']
mysql_config --libs
['-L/usr/local/mysql/lib', '-lmysqlclient', '-lssl', '-lcrypto', '-lresolv']
mysql_config --cflags
['-I/usr/local/mysql/include']
ext_options:
library_dirs: ['/usr/local/mysql/lib']
libraries: ['mysqlclient', 'resolv']
extra_compile_args: ['-std=c99']
extra_link_args: []
include_dirs: ['/usr/local/mysql/include']
extra_objects: []
define_macros: [('version_info', "(2,0,3,'final',0)"), ('__version__', '2.0.3')]
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.9
creating build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
creating build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.macosx-10.9-x86_64-3.9
creating build/temp.macosx-10.9-x86_64-3.9/MySQLdb
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/usr/local/opt/openssl#1.1/include -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.9/MySQLdb/_mysql.o -std=c99
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/setup.py'"'"'; __file__='"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/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/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-record-jl3d35rj/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/mysqlclient Check the logs for full command output.
Please note that I have already checked out many questions opened for this same issue. But none of the suggested fix working for me.
Please help
This Issue is fixed now for me and for that I did 2 things:
1 - Installed wheel package
pip3 install wheel
2 - I followed this thread - Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
try to install the latest version of mysqlclient
mysqlclient==2.0.3
version 2.0.3 worked for me in python 3.9 (win)

unable to install psycopg2 due to large error

I'm trying to install psycopg2 but I keep getting this error:
Collecting psycopg2
Using cached psycopg2-2.8.5.tar.gz (380 kB)
Using legacy setup.py install for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /home/yovel/PycharmProjects/scr/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8vyzoc4h/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8vyzoc4h/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 /tmp/pip-record-fq16err7/install-record.txt --single-version-externally-managed --compile --install-headers /home/yovel/PycharmProjects/scr/venv/include/site/python3.8/psycopg2
cwd: /tmp/pip-install-8vyzoc4h/psycopg2/
Complete output (40 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120002 -DHAVE_LO64=1 -I/home/yovel/PycharmProjects/scr/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.h>
| ^~~~~~~~~~~~
compilation terminated.
It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/yovel/PycharmProjects/scr/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8vyzoc4h/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8vyzoc4h/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 /tmp/pip-record-fq16err7/install-record.txt --single-version-externally-managed --compile --install-headers /home/yovel/PycharmProjects/scr/venv/include/site/python3.8/psycopg2 Check the logs for full command output.
I can install and use it using psycopg2-binary but I need to install this because it's a dependency (for django-heroku).
I tried installing libpq-dev but got this error:
The following packages have unmet dependencies:
libpq-dev : Depends: libpq5 (= 12.2-4) but 12.3-1.pgdg20.04+1 is to be installed
E: Unable to correct problems, you have held broken packages
and using sudo apt-get install libpq5
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.

Can't pip install mysqlclient error on Mac [duplicate]

This question already has answers here:
Error installing mysql-python: library not found for -lssl
(10 answers)
Closed 3 years ago.
I'm unable to install pip install mysqlclient and it returns an error. I want to use the Connector/Python.
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /Users/chichong/MyProject/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-install-uelq41i2/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-install-uelq41i2/mysqlclient/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/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-record-qsanuzxd/install-record.txt --single-version-externally-managed --compile --install-headers /Users/chichong/MyProject/include/site/python3.8/mysqlclient
cwd: /private/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-install-uelq41i2/mysqlclient/
Complete output (30 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb
creating build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/MySQLdb
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 -I/usr/local/Cellar/mysql/8.0.18_1/include/mysql -I/Users/chichong/MyProject/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.8/MySQLdb/_mysql.o
gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.8/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/8.0.18_1/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.8/MySQLdb/_mysql.cpython-38-darwin.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/chichong/MyProject/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-install-uelq41i2/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-install-uelq41i2/mysqlclient/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/var/folders/84/s5lsk989351b8w9j2pjttrb80000gn/T/pip-record-qsanuzxd/install-record.txt --single-version-externally-managed --compile --install-headers /Users/chichong/MyProject/include/site/python3.8/mysqlclient Check the logs for full command output.
======================================
Package Version
---------------------- -------
Django 3.0.1
mysql-connector-python 8.0.18
pip 19.3.1
PyMySQL 0.9.3
sqlparse 0.3.0
Looks like you don't have openssl installed. Try brew install openssl
If you're still getting the error when openssl is installed you'll probably need to:
brew unlink openssl && brew link openssl --force
and then run the export LDFLAGS and export CPPFLAGS comands it outputs.

Can't find Availability.h header file with gcc

When I try to install new python packages with pip, I get the following error. Looks like gcc can't find the Availability.h header file. I've had this problem with multiple python packages so it's not just problem with the library. I'm running Anaconda 2.2.0 and I'm on Mac OS X Yosemite 10.10.2 64-bit .
I tried reinstalling Xcode and Xcode dev tools since it appears to be a problem with gcc, but that didn't work.
beavernet-163:desktop David$ pip install bllipparser
Collecting bllipparser
Using cached bllipparser-2015.01.11.tar.gz
Installing collected packages: bllipparser
Running setup.py install for bllipparser
Complete output from command /Users/David/anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/0d/n030c4312490_6px0bt47_wh0000gn/T/pip-build-X5SLrE/bllipparser/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/0d/n030c4312490_6px0bt47_wh0000gn/T/pip-FzytLX-record/install-record.txt --single-version-externally-managed --compile:
/Users/David/anaconda/lib/python2.7/site-packages/setuptools-14.3-py2.7.egg/setuptools/dist.py:282: UserWarning: Normalizing '2015.01.11' to '2015.1.11'
running install
running build
running build_py
creating build
creating build/lib.macosx-10.5-x86_64-2.7
creating build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/__init__.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/CharniakParser.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/JohnsonReranker.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/ModelFetcher.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/ParsingShell.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/RerankerFeatureCorpus.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
copying python/bllipparser/RerankingParser.py -> build/lib.macosx-10.5-x86_64-2.7/bllipparser
running build_ext
building 'bllipparser._CharniakParser' extension
creating build/temp.macosx-10.5-x86_64-2.7
creating build/temp.macosx-10.5-x86_64-2.7/first-stage
creating build/temp.macosx-10.5-x86_64-2.7/first-stage/PARSE
gcc -fno-strict-aliasing -I/Users/David/anaconda/include -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ifirst-stage/PARSE/ -I/Users/David/anaconda/include/python2.7 -c first-stage/PARSE/parser_wrapper.C -o build/temp.macosx-10.5-x86_64-2.7/first-stage/PARSE/parser_wrapper.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /Users/David/anaconda/include/python2.7/pyport.h:325:0,
from /Users/David/anaconda/include/python2.7/Python.h:58,
from first-stage/PARSE/parser_wrapper.C:155:
/usr/local/lib/gcc/x86_64-apple-darwin12.5.0/4.8.1/include-fixed/math.h:54:26: fatal error: Availability.h: No such file or directory
#include <Availability.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Users/David/anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/0d/n030c4312490_6px0bt47_wh0000gn/T/pip-build-X5SLrE/bllipparser/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/0d/n030c4312490_6px0bt47_wh0000gn/T/pip-FzytLX-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/0d/n030c4312490_6px0bt47_wh0000gn/T/pip-build-X5SLrE/bllipparser
Here is the gcc version.
beavernet-163:desktop David$ gcc --version
gcc: warning: couldn’t understand kern.osversion ‘14.1.0
gcc (GCC) 4.8.1
And Xcode version is 6.2.

Categories

Resources