Failed/error to install psycopg2-binary on termux - python

u0_a439#localhost: /data/data/com.termux/files/home/storage/shared/z_termux
➜ pip3 install psycopg2-binary
i want to install psycopg2-binary on termux, but i got error like this.
Collecting psycopg2-binary
Using cached psycopg2-binary-2.9.3.tar.gz (380 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
running egg_info
creating /data/data/com.termux/files/usr/tmp/pip-pip-egg-info-ayuu7y_q/psycopg2_binary.egg-info
writing /data/data/com.termux/files/usr/tmp/pip-pip-egg-info-ayuu7y_q/psycopg2_binary.egg-info/PKG-INFO
writing dependency_links to /data/data/com.termux/files/usr/tmp/pip-pip-egg-info-ayuu7y_q/psycopg2_binary.egg-info/dependency_links.txt
writing top-level names to /data/data/com.termux/files/usr/tmp/pip-pip-egg-info-ayuu7y_q/psycopg2_binary.egg-info/top_level.txt
writing manifest file '/data/data/com.termux/files/usr/tmp/pip-pip-egg-info-ayuu7y_q/psycopg2_binary.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details. /2.4s
u0_a439#localhost: /data/data/com.termux/files/home/storage/shared/z_termux
➜
I'm very grateful if someone help solve this problem

I think psycopg2-binary package has been pre-built assuming that it would run on a Linux system which uses the glibc implementation as the standard C library. Termux runs on Android, which does not use glibc. So I think what is happening is that pip understands that and falls back to building psycopg from source, in which case the build dependencies should be installed before.
Try installing the build dependencies:
apt-get install libpq-dev gcc python3-dev musl-dev
See https://github.com/psycopg/psycopg2/issues/684
A web search for the same problem shows that this is also the case for other Linux systems that don't use glibc, like Alpine Linux.

Related

LightFM library install error on Sagemaker Notebook

I was using LightFM library on Sagemaker Notebook without any issue before.
However, from yesterday, I started seeing this error message and could no longer complete installation (pip install lightfm)
Building wheels for collected packages: lightfm
Building wheel for lightfm (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [176 lines of output]
/home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/setuptools/dist.py:775: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
...
...
...
...
In file included from /home/ec2-user/anaconda3/envs/python3/include/python3.10/unicodeobject.h:1046:0,
from /home/ec2-user/anaconda3/envs/python3/include/python3.10/Python.h:83,
from lightfm/_lightfm_fast_openmp.c:20:
/home/ec2-user/anaconda3/envs/python3/include/python3.10/cpython/unicodeobject.h:551:42: note: declared here
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
^~~~~~~~~~~~~~~~~~~~~
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> lightfm
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
I tried several suggestions I found from web, such as
pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade setuptools
pip install Cmake
pip install requests --no-dependencies
but none of these worked - still getting same error message.
How should I mitigate from this error?
This seems to be an issue with the lightfm package installation. Have you tried installing this in another environment? This can also be dependent on the notebook kernel you are using. Can you try installing in a virtual environment as well?

Trying to install selectorlib package in Python

I am trying to install a selectorlib package using:
Importing:
import selectorlib
Installing in terminal:
pip install selectorlib
And i get this error:
...
Building wheel for lxml (setup.py)
error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
[115 lines of output]
...
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for lxml
Running setup.py clean for lxml
Failed to build lxml
Installing collected packages: lxml, cssselect, Click, parsel, selectorlib
Running setup.py install for lxml ... error
error: subprocess-exited-with-error
× Running setup.py install for lxml did not run successfully.
│ exit code: 1
...
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
...
Y tried different methods in order to install it:
Using different interpreters (Python 3.9.6; Python 3.10.9; Python 3.11.1)
Tried to install in VS Code and PyCharm CE
Tried to install different selectorlib versions. (Last 3)
Assuming you are working on a unix platform, lxml requires some C dependencies before it can be installed with pip.
You can check the official installation instructions.
Unless you are using a static binary distribution (e.g. from a Windows
binary installer), lxml requires libxml2 and libxslt to be installed,
in particular:
libxml2 version 2.9.2 or later.
libxslt version 1.1.27 or later.
We recommend libxslt 1.1.28 or later.
According to these instructions, you have to install the dependencies via
sudo apt-get install libxml2-dev libxslt-dev python-dev

why do I see this error when I try to install Openai Whisper

PS C:\> pip install git+https://github.com/openai/whisper.git
Collecting git+https://github.com/openai/whisper.git
Cloning https://github.com/openai/whisper.git to c:\users\minju\appdata\local\temp\pip-req-build-aaszmdk8
Running command git clone --filter=blob:none --quiet https://github.com/openai/whisper.git 'C:\Users\minju\AppData\Local\Temp\pip-req-build-aaszmdk8'
Resolved https://github.com/openai/whisper.git to commit 28769fcfe50755a817ab922a7bc83483159600a9
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
It's via VS code, and I don't know what's the problem.
Both git and pip are operating fine.
How can I solve that?
You need setuptools installed in your environment. So try pip install setuptools in your terminal, and then retry your installation.

Unable to install pwn package for python

I am trying to install the pwn library on my MacBook Air (M2, 2022) but it's failing while building the wheel for unicorn. I'm using python version 3.10.6.
This is the command I'm using: python3 -m pip install --upgrade pwn
without the --upgrade part I still get the same error message.
If I replace pwn with pwntools I still get the same error message as well.
wtdcode stated in the GitHub issue:
"Due to the fact that GitHub doesn't provide an M1 CI (actions/runner-images#2187), there is no available PyPI release yet. You may build it by yourself."
So my question is, How do I build it myself?
error msg:
Building wheel for unicorn (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [4 lines of output]
running bdist_wheel
running build
Building C extensions
error: [Errno 2] No such file or directory: '/private/var/folders/6d/85dtjcrj57173csw50tk8r300000gn/T/pip-install-o33_11sd/unicorn_530dd415f77a40418edfdec7c2d599f2/../../include/unicorn'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for unicorn
Running setup.py clean for unicorn
Successfully built psutil
Failed to build unicorn
Installing collected packages: unicorn, pyserial, pyelftools, rpyc, ropgadget, requests, python-dateutil, pysocks, psutil, pathlib2, packaging, mako, intervaltree, colored-traceback, paramiko, pwntools, pwn
Running setup.py install for unicorn ... error
error: subprocess-exited-with-error
× Running setup.py install for unicorn did not run successfully.
│ exit code: 1
╰─> [4 lines of output]
running install
running build
Building C extensions
error: [Errno 2] No such file or directory: '/private/var/folders/6d/85dtjcrj57173csw50tk8r300000gn/T/pip-install-o33_11sd/unicorn_530dd415f77a40418edfdec7c2d599f2/../../include/unicorn'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> unicorn
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Thank you for your help.
I have an M1 mac and had the same issue—nothing worked for me either, so I eventually just tried installing an older version of unicorn (if you do pip install unicorn== without specifying the version, you can list all of them), and tried different ones until one worked.
(For me, this was just downgrading to 2.0.0)
According to official pwntools documentation, you need building binutils from source. They did make things easy with homebrew:
brew install https://raw.githubusercontent.com/Gallopsled/pwntools-binutils/master/macos/binutils-$ARCH.rb
In order to be able to call the library from Python interpreter, an extra step for me was to use the virtualenv:
source /opt/homebrew/Cellar/pwntools/{PWNTOOLS_VERSION}/libexec/bin/activate

Issues installing python typedb-client on macOs m1 architecture

When I try to install the python typedb-client using pip, I get several errors concerning grpcio:
Building wheels for collected packages: grpcio
Building wheel for grpcio (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [21870 lines of output]
ASM Builds for BoringSSL currently not supported on: macosx-11.1-arm64
as well as many lines of:
...
distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
...
This happens both on global installation and in conda environments...
After searching for grpcio installation issues on the M1 architecture, the solution for me was to prepend the following to the pip command:
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install typedb-client==2.9.0
in some cases, should you see ssl errors, you can extend that command to:
CFLAGS="-I /opt/homebrew/opt/openssl/include" LDFLAGS="-L /opt/homebrew/opt/openssl/lib" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install typedb-client==2.9.0
assuming that you have openssl install via homebrew. This tells pip where to look for appropriate headers and code to build the grpcio pip package.

Categories