Failed to run TA-lib Python on Heroku - python

I want to deploy an app using Heroku but it did not manage to build it. See my build logs under this message.
It looks that my problem is that it cannot load/install Ta-Lib (package that I want to use).
I have 4 documents in my git project:
Procfile
worker: python StrategyMade.py
1 file with my python code called StrategyMade.py
config.json (which is settings that I need for the python code)
requirements.txt (all my packages used)
freqtrade
pandas
numpy
matplotlib
I read online that I need to have buildpacks for Ta-lib so I installed Heroku CLI and then went to terminal and typed the commands in my terminal:
heroku buildpacks:add --index 1 heroku/python -a "name of my project"
heroku buildpacks:add --index 2 numrut/ta-lib -a "name of my project"
and checked if this is added which is true:
screenshot
I ran the app but it gave me some errors. Can someone help me to figure out what is wrong and how I can solve this?Thanks!
Here are my build logs
Building wheel for blosc (PEP 517): finished with status 'done'
Created wheel for blosc: filename=blosc-1.10.2-cp36-cp36m-linux_x86_64.whl size=2311541 sha256=ceefb8ef23ea2204edd8b3551f2052561c4b9d39d3262c8b0e08b7329f35a7fa
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/25/ac/11/5268f9b74f868f4c55d3fa63e4e350543d93e4bd1035e66bfd
Building wheel for TA-Lib (setup.py): started
Building wheel for TA-Lib (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-s_lykcmr
cwd: /tmp/pip-install-iwphzu1f/TA-Lib/
Complete output (27 lines):
/tmp/pip-install-iwphzu1f/TA-Lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
warnings.warn('Cannot find ta-lib library, installation may fail.')
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/talib
copying talib/test_stream.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_func.py -> build/lib.linux-x86_64-3.6/talib
copying talib/deprecated.py -> build/lib.linux-x86_64-3.6/talib
copying talib/abstract.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_abstract.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_pandas.py -> build/lib.linux-x86_64-3.6/talib
copying talib/stream.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_data.py -> build/lib.linux-x86_64-3.6/talib
copying talib/__init__.py -> build/lib.linux-x86_64-3.6/talib
running build_ext
building 'talib._ta_lib' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/talib
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/tmp/pip-install-iwphzu1f/TA-Lib/.eggs/numpy-1.19.5-py3.6-linux-x86_64.egg/numpy/core/include -I/app/.heroku/python/include/python3.6m -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.6/talib/_ta_lib.o
talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
611 | #include "ta-lib/ta_defs.h"
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for TA-Lib
Running setup.py clean for TA-Lib
Building wheel for sdnotify (setup.py): started
Building wheel for sdnotify (setup.py): finished with status 'done'
Created wheel for sdnotify: filename=sdnotify-0.3.2-py3-none-any.whl size=3212 sha256=1361286b816e23a732caf82e2b98021e5b86ad57082d47b40339832ce585e4fc
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/ad/c7/fb/b9012fda1d8f9e7749915eab363b35fcd09b3a7f699f2a5ae1
Building wheel for wrapt (setup.py): started
Building wheel for wrapt (setup.py): finished with status 'done'
Created wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_x86_64.whl size=75931 sha256=83225a868b63939b67454f0018cf7ba94c4030e0e31ab09b67f5a5b710eec0d4
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63
Building wheel for py-find-1st (PEP 517): started
Building wheel for py-find-1st (PEP 517): finished with status 'done'
Created wheel for py-find-1st: filename=py_find_1st-1.1.5-cp36-cp36m-linux_x86_64.whl size=36443 sha256=6d269bbd6bc8578f2f937a46c41ab25d8e084b63e170fa02bce30689b5c4642a
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/90/8d/80/93609354b7435b7f4c3d53407658592cb07bb53e40d9b6015e
Building wheel for pyrsistent (setup.py): started
Building wheel for pyrsistent (setup.py): finished with status 'done'
Created wheel for pyrsistent: filename=pyrsistent-0.17.3-cp36-cp36m-linux_x86_64.whl size=129178 sha256=185ff665281b7f54f0da6d0bb6534cee10f21ce9481ae72fda966e100d1812c5
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/34/13/19/294da8e11bce7e563afee51251b9fa878185e14f4b5caf00cb
Building wheel for idna-ssl (setup.py): started
Building wheel for idna-ssl (setup.py): finished with status 'done'
Created wheel for idna-ssl: filename=idna_ssl-1.1.0-py3-none-any.whl size=3161 sha256=57671bb402e032f7df82fbd0ed50792447c82e9a5b7a712f6698c63a78833cfa
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/6a/f5/9c/f8331a854f7a8739cf0e74c13854e4dd7b1af11b04fe1dde13
Building wheel for typing (setup.py): started
Building wheel for typing (setup.py): finished with status 'done'
Created wheel for typing: filename=typing-3.7.4.3-py3-none-any.whl size=26308 sha256=05c526d654cdd48ab5d66e1c8192840c3844d5bce1cbc6cc9da625f772987b43
Stored in directory: /tmp/pip-ephem-wheel-cache-kmy3d35j/wheels/5f/63/c2/b85489bbea28cb5d36cfe197244f898428004fa3caa7a23116
Successfully built blosc sdnotify wrapt py-find-1st pyrsistent idna-ssl typing
Failed to build TA-Lib
Installing collected packages: tabulate, chardet, urllib3, idna, certifi, requests, wcwidth, prompt-toolkit, questionary, numpy, six, python-dateutil, pytz, pandas, blosc, multidict, yarl, pycparser, cffi, cryptography, idna-ssl, attrs, async-timeout, typing-extensions, aiohttp, pycares, typing, aiodns, ccxt, numexpr, tables, MarkupSafe, jinja2, zipp, importlib-metadata, pyrsistent, jsonschema, cachetools, pycoingecko, TA-Lib, sdnotify, greenlet, SQLAlchemy, python-rapidjson, arrow, wrapt, colorama, py-find-1st, tzlocal, APScheduler, tornado, python-telegram-bot, freqtrade, pillow, kiwisolver, pyparsing, cycler, matplotlib
Running setup.py install for TA-Lib: started
Running setup.py install for TA-Lib: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-iwphzu1f/TA-Lib/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-kyza1uz5/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.6m/TA-Lib
cwd: /tmp/pip-install-iwphzu1f/TA-Lib/
Complete output (27 lines):
/tmp/pip-install-iwphzu1f/TA-Lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
warnings.warn('Cannot find ta-lib library, installation may fail.')
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/talib
copying talib/test_stream.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_func.py -> build/lib.linux-x86_64-3.6/talib
copying talib/deprecated.py -> build/lib.linux-x86_64-3.6/talib
copying talib/abstract.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_abstract.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_pandas.py -> build/lib.linux-x86_64-3.6/talib
copying talib/stream.py -> build/lib.linux-x86_64-3.6/talib
copying talib/test_data.py -> build/lib.linux-x86_64-3.6/talib
copying talib/__init__.py -> build/lib.linux-x86_64-3.6/talib
running build_ext
building 'talib._ta_lib' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/talib
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/app/.heroku/python/lib/python3.6/site-packages/numpy/core/include -I/app/.heroku/python/include/python3.6m -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.6/talib/_ta_lib.o
talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
611 | #include "ta-lib/ta_defs.h"
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-iwphzu1f/TA-Lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-iwphzu1f/TA-Lib/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-kyza1uz5/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.6m/TA-Lib Check the logs for full command output.
! Push rejected, failed to compile Python app.
! Push failed

TA-Lib is a C library. It has a python wrapper with the same name TA-Lib. The C code must be downloaded and compiled before python wrapper installation. According to your log something tries to install wrapper while C library isn't installed to the system. But it seems numrut/ta-lib buildpack is aware of this.
It seems the problem is that freqtrade in your requirements.txt depends on TA-Lib python wrapper. And numrut/ta-lib is trying to install requirements from requirements.txt with pip before it compiles C source and installs TA-Lib wrapper (with pip again). So ta-lib wrapper is trying to be installed twice. And first attempt is made before C sources are compiled which is a fault.
The possible solution would be to remove freqtrade from requirements.txt and somehow execute pip install -r freqtrade after buildpack numrut/ta-lib is executed. But I don't know Heroku and not sure how to do this and if this is possible at all. Another options would be: to fork numrut/ta-lib buildpack and make this change it its scriptm then use own fork instead of it. Or to address this issue to numrut/ta-lib author - perhaps he bypass this problem in his script. Or to address this issue to freqtrade authors and ask them to make own buildpack for Heroku.

If your running Ubuntu, you can run
sudo apt-get update
sudo apt-get install gcc python3.9
You might not even need python3.9, gcc alone might do it
If not ubuntu, use yum or whatever your OS uses

Related

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

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.

How to include non-Python dependencies in a Python Django deployment?

I am deploying a Django application using Heroku. One of my application's dependencies is the 'ta-lib' library, which is a Python wrapper for a library written in C. To get this to work locally, I simply had to download the underlying C library and the program would pick up what it needed from /usr/local and I had no problems.
Library reference: https://mrjbq7.github.io/ta-lib/install.html
Now, when I'm trying to push my files to Heroku via Git, the build fails at this library. Here is the terminal output, starting from where the errors began:
remote: Building wheel for TA-Lib (setup.py): started
remote: Building wheel for TA-Lib (setup.py): finished with status 'error'
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ya1rkeoc/ta-lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ya1rkeoc/ta-lib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-e83ejfm_
remote: cwd: /tmp/pip-install-ya1rkeoc/ta-lib/
remote: Complete output (27 lines):
remote: /tmp/pip-install-ya1rkeoc/ta-lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
remote: warnings.warn('Cannot find ta-lib library, installation may fail.')
remote: running bdist_wheel
remote: running build
remote: running build_py
remote: creating build
remote: creating build/lib.linux-x86_64-3.9
remote: creating build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_data.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_func.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/stream.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/__init__.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/deprecated.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_pandas.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_stream.py -> build/lib.linux-x86_64-3.9/talib
remote: running build_ext
remote: building 'talib._ta_lib' extension
remote: creating build/temp.linux-x86_64-3.9
remote: creating build/temp.linux-x86_64-3.9/talib
remote: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/tmp/pip-install-ya1rkeoc/ta-lib/.eggs/numpy-1.20.3-py3.9-linux-x86_64.egg/numpy/core/include -I/app/.heroku/python/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o
remote: talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
remote: 611 | #include "ta-lib/ta_defs.h"
remote: | ^~~~~~~~~~~~~~~~~~
remote: compilation terminated.
remote: error: command '/usr/bin/gcc' failed with exit code 1
remote: ----------------------------------------
remote: ERROR: Failed building wheel for TA-Lib
remote: Running setup.py clean for TA-Lib
remote: Building wheel for wrapt (setup.py): started
remote: Building wheel for wrapt (setup.py): finished with status 'done'
remote: Created wheel for wrapt: filename=wrapt-1.12.1-cp39-cp39-linux_x86_64.whl size=78588 sha256=bcbc0270be5d84ca062d30a118d3e1b5bb48b1eb96ca15d72db3ba00e95e33dc
remote: Stored in directory: /tmp/pip-ephem-wheel-cache-xcx232so/wheels/98/23/68/efe259aaca055e93b08e74fbe512819c69a2155c11ba3c0f10
remote: Successfully built lazy-object-proxy wrapt
remote: Failed to build TA-Lib
remote: Installing collected packages: asgiref, six, wrapt, lazy-object-proxy, astroid, certifi, chardet, Cython, pytz, sqlparse, Django, gunicorn, idna, isort, mccabe, numpy, urllib3, requests, pycoingecko, toml, pylint, TA-Lib, typed-ast
remote: Running setup.py install for TA-Lib: started
remote: Running setup.py install for TA-Lib: finished with status 'error'
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ya1rkeoc/ta-lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ya1rkeoc/ta-lib/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-l9p7ava0/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/TA-Lib
remote: cwd: /tmp/pip-install-ya1rkeoc/ta-lib/
remote: Complete output (28 lines):
remote: /tmp/pip-install-ya1rkeoc/ta-lib/setup.py:71: UserWarning: Cannot find ta-lib library, installation may fail.
remote: warnings.warn('Cannot find ta-lib library, installation may fail.')
remote: running install
remote: running build
remote: running build_py
remote: creating build
remote: creating build/lib.linux-x86_64-3.9
remote: creating build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_data.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_func.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/stream.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/__init__.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/abstract.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/deprecated.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_pandas.py -> build/lib.linux-x86_64-3.9/talib
remote: copying talib/test_stream.py -> build/lib.linux-x86_64-3.9/talib
remote: running build_ext
remote: skipping 'talib/_ta_lib.c' Cython extension (up-to-date)
remote: building 'talib._ta_lib' extension
remote: creating build/temp.linux-x86_64-3.9
remote: creating build/temp.linux-x86_64-3.9/talib
remote: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/app/.heroku/python/lib/python3.9/site-packages/numpy/core/include -I/app/.heroku/python/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o
remote: talib/_ta_lib.c:611:10: fatal error: ta-lib/ta_defs.h: No such file or directory
remote: 611 | #include "ta-lib/ta_defs.h"
remote: | ^~~~~~~~~~~~~~~~~~
remote: compilation terminated.
remote: error: command '/usr/bin/gcc' failed with exit code 1
remote: ----------------------------------------
remote: ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ya1rkeoc/ta-lib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ya1rkeoc/ta-lib/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-l9p7ava0/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/TA-Lib Check the logs for full command output.
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to <my-app-name>.
remote:
To https://git.heroku.com/<my-app-name>.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/<my-app-name>.git'enter code here
How do I determine which files from the underlying C library are needed and where do I add them to my Django project when pushing my code?
Thank you.

How does one install pygraphviz on a HPC cluster without errors even when graphviz seems to be installed?

I was trying to pip and conda install pygraphviz. I believe grahviz is installed since
(metalearningpy1.7.1c10.2) miranda9~/ML4Coq $ conda install -y graphviz
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
but when I try installing pygraphviz with pip I get the following:
(metalearningpy1.7.1c10.2) miranda9~/ML4Coq $ pip install pygraphviz
Collecting pygraphviz
Using cached pygraphviz-1.7.zip (118 kB)
Building wheels for collected packages: pygraphviz
Building wheel for pygraphviz (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-b61bb2uf
cwd: /tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/
Complete output (55 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/scraper.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/testing.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/graphviz.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/agraph.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/__init__.py -> build/lib.linux-x86_64-3.8/pygraphviz
creating build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_subgraph.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_readwrite.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_unicode.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_drawing.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_string.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_close.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_scraper.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_edge_attributes.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_graph.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_html.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_clear.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/__init__.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_node_attributes.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_layout.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
running egg_info
writing pygraphviz.egg-info/PKG-INFO
writing dependency_links to pygraphviz.egg-info/dependency_links.txt
writing top-level names to pygraphviz.egg-info/top_level.txt
reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.png' under directory 'doc'
warning: no files found matching '*.txt' under directory 'doc'
warning: no files found matching '*.css' under directory 'doc'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'doc/build'
writing manifest file 'pygraphviz.egg-info/SOURCES.txt'
copying pygraphviz/graphviz.i -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/graphviz_wrap.c -> build/lib.linux-x86_64-3.8/pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/pygraphviz
gcc -pthread -B /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-3.8/pygraphviz/graphviz_wrap.o
In file included from /usr/include/graphviz/gvc.h:17:0,
from pygraphviz/graphviz_wrap.c:2712:
/usr/include/graphviz/types.h:49:20: fatal error: cgraph.h: No such file or directory
#include <cgraph.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pygraphviz
Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz ... error
ERROR: Command errored out with exit status 1:
command: /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/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-mu112lx1/install-record.txt --single-version-externally-managed --compile --install-headers /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/include/python3.8/pygraphviz
cwd: /tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/
Complete output (55 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/pygraphviz
copying pygraphviz/scraper.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/testing.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/graphviz.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/agraph.py -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/__init__.py -> build/lib.linux-x86_64-3.8/pygraphviz
creating build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_subgraph.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_readwrite.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_unicode.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_drawing.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_string.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_close.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_scraper.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_edge_attributes.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_graph.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_html.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_clear.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/__init__.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_node_attributes.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
copying pygraphviz/tests/test_layout.py -> build/lib.linux-x86_64-3.8/pygraphviz/tests
running egg_info
writing pygraphviz.egg-info/PKG-INFO
writing dependency_links to pygraphviz.egg-info/dependency_links.txt
writing top-level names to pygraphviz.egg-info/top_level.txt
reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.png' under directory 'doc'
warning: no files found matching '*.txt' under directory 'doc'
warning: no files found matching '*.css' under directory 'doc'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'doc/build'
writing manifest file 'pygraphviz.egg-info/SOURCES.txt'
copying pygraphviz/graphviz.i -> build/lib.linux-x86_64-3.8/pygraphviz
copying pygraphviz/graphviz_wrap.c -> build/lib.linux-x86_64-3.8/pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/pygraphviz
gcc -pthread -B /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-3.8/pygraphviz/graphviz_wrap.o
In file included from /usr/include/graphviz/gvc.h:17:0,
from pygraphviz/graphviz_wrap.c:2712:
/usr/include/graphviz/types.h:49:20: fatal error: cgraph.h: No such file or directory
#include <cgraph.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rc_2rzek/pygraphviz_904720f7fa8b49f4a7006870a0d5e479/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-mu112lx1/install-record.txt --single-version-externally-managed --compile --install-headers /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/include/python3.8/pygraphviz Check the logs for full command output.
with conda:
(metalearningpy1.7.1c10.2) miranda9~/ML4Coq $ conda install -y -c anaconda pygraphviz
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages. failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- pygraphviz -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
what are the sources of my errors? [note I am on a linux machine, not mac os, my mac phygraphviz works fine]
I saw the following related questions:
Pip install pygraphviz fails: Failed building wheel for pygraphviz
Couldn't install pygraphviz
https://github.com/pygraphviz/pygraphviz/issues/347
https://github.com/pygraphviz/pygraphviz/issues/358
but they didn't help because I cannot run apt-get
(metalearningpy1.7.1c10.2) miranda9~/ML4Coq $ apt-get install python-dev graphviz libgraphviz-dev pkg-config
-bash: apt-get: command not found
Edit:
note I also did try to install grapviz with pip but that didn't solve my problems:
(metalearningpy1.7.1c10.2) miranda9~/ML4Coq $ pip install graphviz
Collecting graphviz
Downloading graphviz-0.16-py2.py3-none-any.whl (19 kB)
Installing collected packages: graphviz
Successfully installed graphviz-0.16
Edit 2:
I found out that graphviz is there but why can't it find it?
(metalearningpy1.7.1c10.2) miranda9~ $ rpm -qa |grep graphviz
graphviz-gd-2.30.1-21.el7.x86_64
graphviz-2.30.1-21.el7.x86_64
graphviz-devel-2.30.1-21.el7.x86_64
Edit 3:
I'd also like this to work with pip install -e . e.g. see installation of ultimate utils (https://github.com/brando90/ultimate-utils):
Due to a depedency on pygraphviz you will likely need to install graphviz first. Next, install graphviz. On mac, brew install graphviz. On Ubuntu, sudo apt install graphviz. After graphviz is install, install uutils in edibable mode and all it's depedencies with pip:
pip install -e ~/ultimate-utils/ultimate-utils-proj-src
as a gitissue: https://github.com/brando90/ultimate-utils/issues/6
Well, it seems that using conda-forge worked!
(metalearningpy1.7.1c10.2) miranda9~ $ conda install -y -c conda-forge pygraphviz
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2
added / updated specs:
- pygraphviz
The following packages will be downloaded:
package | build
---------------------------|-----------------
libgcc-ng-9.3.0 | h2828fa1_19 7.8 MB conda-forge
libgomp-9.3.0 | h2828fa1_19 376 KB conda-forge
pygraphviz-1.7 | py38h0d738da_0 125 KB conda-forge
------------------------------------------------------------
Total: 8.3 MB
The following NEW packages will be INSTALLED:
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-1_gnu
libgomp conda-forge/linux-64::libgomp-9.3.0-h2828fa1_19
pygraphviz conda-forge/linux-64::pygraphviz-1.7-py38h0d738da_0
The following packages will be UPDATED:
certifi pkgs/main::certifi-2020.12.5-py38h06a~ --> conda-forge::certifi-2020.12.5-py38h578d9bd_1
libgcc-ng pkgs/main::libgcc-ng-9.1.0-hdf63c60_0 --> conda-forge::libgcc-ng-9.3.0-h2828fa1_19
The following packages will be SUPERSEDED by a higher-priority channel:
_libgcc_mutex pkgs/main::_libgcc_mutex-0.1-main --> conda-forge::_libgcc_mutex-0.1-conda_forge
ca-certificates pkgs/main::ca-certificates-2021.4.13-~ --> conda-forge::ca-certificates-2020.12.5-ha878542_0
openssl pkgs/main::openssl-1.1.1k-h27cfd23_0 --> conda-forge::openssl-1.1.1k-h7f98852_0
Downloading and Extracting Packages
libgcc-ng-9.3.0 | 7.8 MB | ##################################################################################################################################################################################################################################################################################################################################################################################### | 100%
pygraphviz-1.7 | 125 KB | ##################################################################################################################################################################################################################################################################################################################################################################################### | 100%
libgomp-9.3.0 | 376 KB | ##################################################################################################################################################################################################################################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Note:
However, notice that pygraphviz doesn't recommend using conda to install their pkg for some reason
We recommend avoiding Anaconda and conda-forge to install Graphviz and PyGraphviz.
however since pip keeps failing for me - despite graphviz being installed in the cluster - see the output of rpm:
[rundblom#vision-12 ~]$ rpm -qa |grep graphviz
graphviz-devel-2.30.1-21.el7.x86_64
graphviz-2.30.1-21.el7.x86_64
graphviz-gd-2.30.1-21.el7.x86_64
so idk what is wrong with using pip. I would have preferred to load a module in the usual HPC way but that isn't an option for me right now...
I was able to compile it on CentOS with graphviz-devel installed. Originally I got the same error as above, the missing cgraph.h, but by providing a header lookup path to the compiler I could make it build:
CPPFLAGS="-I/usr/include/graphviz" pip install pygraphviz
When I tried to use the package though I had symbol lookup errors. So in the end I gave up and went with conda.

Unable to install sasl on MAC

In order to connect to Hive data warehouse from python.
Using pyhive requires sasl - ModuleNotFoundError: No module named 'sasl'
Installing sasl fails with errors below
Python 3.9.4
installed gcc, libsasl2
MACOS Mojave v 10.14
pip3 install sasl
Collecting sasl
Using cached sasl-0.2.1.tar.gz (30 kB)
Requirement already satisfied: six in /usr/local/lib/python3.9/site-packages (from sasl) (1.15.0)
Building wheels for collected packages: sasl
Building wheel for sasl (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/python#3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7l/zbp16k6s11v5rypxj86mq_z00000gn/T/pip-install-3a1mge3r/sasl_ebeeb9cd2f6b4067a93195d45bbf68c1/setup.py'"'"'; __file__='"'"'/private/var/folders/7l/zbp16k6s11v5rypxj86mq_z00000gn/T/pip-install-3a1mge3r/sasl_ebeeb9cd2f6b4067a93195d45bbf68c1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/7l/zbp16k6s11v5rypxj86mq_z00000gn/T/pip-wheel-r3vsh0mm
cwd: /private/var/folders/7l/zbp16k6s11v5rypxj86mq_z00000gn/T/pip-install-3a1mge3r/sasl_ebeeb9cd2f6b4067a93195d45bbf68c1/
Complete output (333 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.9
creating build/lib.macosx-10.14-x86_64-3.9/sasl
copying sasl/__init__.py -> build/lib.macosx-10.14-x86_64-3.9/sasl
running egg_info
writing sasl.egg-info/PKG-INFO
writing dependency_links to sasl.egg-info/dependency_links.txt
writing requirements to sasl.egg-info/requires.txt
writing top-level names to sasl.egg-info/top_level.txt
reading manifest file 'sasl.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'sasl.egg-info/SOURCES.txt'
copying sasl/saslwrapper.cpp -> build/lib.macosx-10.14-x86_64-3.9/sasl
copying sasl/saslwrapper.h -> build/lib.macosx-10.14-x86_64-3.9/sasl
copying sasl/saslwrapper.pyx -> build/lib.macosx-10.14-x86_64-3.9/sasl
running build_ext
building 'sasl.saslwrapper' extension
creating build/temp.macosx-10.14-x86_64-3.9
creating build/temp.macosx-10.14-x86_64-3.9/sasl
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Isasl -I/usr/local/include -I/usr/local/opt/openssl#1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/opt/python#3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c sasl/saslwrapper.cpp -o build/temp.macosx-10.14-x86_64-3.9/sasl/saslwrapper.o
In file included from sasl/saslwrapper.cpp:254:
sasl/saslwrapper.h:36:35: warning: 'sasl_dispose' is deprecated: first deprecated in macOS 10.11 [-Wdeprecated-declarations]
~ClientImpl() { if (conn) sasl_dispose(&conn); conn = 0; }
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sasl/sasl.h:746:18: note: 'sasl_dispose' has been explicitly marked deprecated here
LIBSASL_API void sasl_dispose(sasl_conn_t **pconn) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_11,__IPHONE_NA,__IPHONE_NA);
^
In file included from sasl/saslwrapper.cpp:254:
sasl/saslwrapper.h:179:18: warning: 'sasl_client_init' is deprecated: first deprecated in macOS 10.11 [-Wdeprecated-declarations]
result = sasl_client_init(0);
....
It doesn't support Python3.9 yet
Python 3.7 works
Thank you for your attention folks :)

Why cant I install mysqlclient==1.3.10

I'm using a new MacOS High Sierra 10.13.5.
I first installed python3 using Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install python
then I cloned my python project repository from github which has a requirements.txt file which has the line:
mysqlclient==1.3.10
I then created a virtual env and ran pip install:
python3 -m venv venv
pip install -r api/requirements.txt
and then I get the following error:
...
...
Installing collected packages: six, python-dateutil, aniso8601,
appdirs, jmespath, docutils, botocore, s3transfer, boto3, click, Werkzeug, itsdangerous, MarkupSafe, Jinja2, Flask, Flask-Cors, blinker, Flask-Mail, jsonschema, pytz, flask-restplus, Flask-Script, SQLAlchemy, Flask-SQLAlchemy, Flask-SQLAlchemy-Session, Mako, python-editor, alembic, Flask-Migrate, PyJWT, Flask-JWT-Simple, idna, pycparser, cffi, asn1crypto, cryptography, chardet, certifi, urllib3, requests, nexmo, pyparsing, packaging, Pillow, phonenumbers, numpy, timezonefinder, decorator, ratelim, geocoder, SQLAlchemy-Utils, mysqlclient, pycrypto, simple-crypt, suds-jurko, Salesforce-FuelSDK, schedule, python-utils, progressbar2, timeago
Running setup.py install for aniso8601 ... done
Running setup.py install for itsdangerous ... done
Running setup.py install for MarkupSafe ... done
Running setup.py install for blinker ... done
Running setup.py install for Flask-Mail ... done
Running setup.py install for Flask-Script ... done
Running setup.py install for SQLAlchemy ... done
Running setup.py install for Flask-SQLAlchemy-Session ... done
Running setup.py install for Mako ... done
Running setup.py install for python-editor ... done
Running setup.py install for Flask-JWT-Simple ... done
Running setup.py install for pycparser ... done
Running setup.py install for geocoder ... done
Running setup.py install for SQLAlchemy-Utils ... done
Running setup.py install for mysqlclient ... error
Complete output from command /Users/mvi/mvi/server/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-install-vls9kk27/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/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-record-6eq5p42p/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mvi/mvi/server/venv/include/site/python3.7/mysqlclient:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.13-x86_64-3.7
copying _mysql_exceptions.py -> build/lib.macosx-10.13-x86_64-3.7
creating build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb
creating build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.13-x86_64-3.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.13-x86_64-3.7
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/mysql/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/Users/mvi/mvi/server/venv/include -I/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c _mysql.c -o build/temp.macosx-10.13-x86_64-3.7/_mysql.o
_mysql.c:29:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/Users/mvi/mvi/server/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-install-vls9kk27/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/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-record-6eq5p42p/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mvi/mvi/server/venv/include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/zh/p8bfpbd166758zz6vj60jd100000gn/T/pip-install-vls9kk27/mysqlclient/
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
On my old mac book pro where I did not have this problem.
On that macbook I have python 3.6.5 using GCC 4.2.1.
On this new macbook I have python 3.7 using clang 9.1.0
(venv) $ python
Python 3.7.0 (default, Aug 22 2018, 15:22:33)
[Clang 9.1.0 (clang-902.0.39.2)] on darwin
This article is the only thing I can that seems related but doesnt seem to help much...
https://medium.com/#MrWeeble/homebrew-on-mac-and-pythons-mysqlclient-ea44fa300e70
any ideas for debugging would be appreciated. Thanks.
You need the MySQL client library and its related headers.
These are supplied in e.g. the MariaDB (MySQL fork) package in Brew, so brew install mariadb should do the trick.

Categories

Resources