monty888 / monstr_terminal

some terminal apps for nostr using monstr, the monstr files are currently embedded for the time being, until monstr becomes a proper module if I can ever work out how...
MIT License
17 stars 8 forks source link

Install failed on WSL2 #3

Closed arkin0x closed 1 year ago

arkin0x commented 1 year ago

Following the install instructions failed on the pip install -r requirements.txt step with the following error:

Collecting psycopg2>=2.9.6
  Using cached psycopg2-2.9.6.tar.gz (383 kB)
    ERROR: Command errored out with exit status 1:
     command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-skjcfjl2/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-skjcfjl2/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-skjcfjl2/psycopg2/pip-egg-info
         cwd: /tmp/pip-install-skjcfjl2/psycopg2/
    Complete output (23 lines):
    running egg_info
    creating /tmp/pip-install-skjcfjl2/psycopg2/pip-egg-info/psycopg2.egg-info
    writing /tmp/pip-install-skjcfjl2/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I found that pg_config was not in my PATH.

I first tried to install the binary version of psycopg2 as suggested by the error message, using the instructions found here: https://www.psycopg.org/docs/install.html

pip install psychopg2-binary

After this, I tried pip install -r requirements.txt and got a little further, but then got a different error message that told me to install:

apt install libpq-dev apt install postgresql-common

I did that. This fixed my PATH so that pg_config returned what looked like a proper response:

/mnt/c/www/nostr/monstr_terminal# pg_config
BINDIR = /usr/lib/postgresql/12/bin
DOCDIR = /usr/share/doc/postgresql-doc-12
HTMLDIR = /usr/share/doc/postgresql-doc-12
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/12/server
LIBDIR = /usr/lib/x86_64-linux-gnu
PKGLIBDIR = /usr/lib/postgresql/12/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/12/man
SHAREDIR = /usr/share/postgresql/12
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/12/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=/usr/include' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-silent-rules' '--libdir=/usr/lib/x86_64-linux-gnu' '--libexecdir=/usr/lib/x86_64-linux-gnu' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' 'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/12/man' '--docdir=/usr/share/doc/postgresql-doc-12' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/12' '--bindir=/usr/lib/postgresql/12/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Ubuntu 12.15-0ubuntu0.20.04.1)' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' '--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' 'LLVM_CONFIG=/usr/bin/llvm-config-10' 'CLANG=/usr/bin/clang-10' '--with-systemd' '--with-selinux' 'MKDIR_P=/bin/mkdir -p' 'TAR=/bin/tar' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' '--with-includes=/usr/include/mit-krb5' '--with-libs=/usr/lib/mit-krb5' '--with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5' 'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
CC = gcc
CPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/mit-krb5
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-10/lib -L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,--as-needed
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lpthread -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -ledit -lrt -lcrypt -ldl -lm
VERSION = PostgreSQL 12.15 (Ubuntu 12.15-0ubuntu0.20.04.1)

Now when I run pip install -r requirements.txt I get this:

/mnt/c/www/nostr/monstr_terminal# pip install -r requirements.txt
Requirement already satisfied: aioconsole>=0.6.1 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (0.6.1)
Requirement already satisfied: aiohttp>=3.8.4 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (3.8.4)
Requirement already satisfied: aiosqlite>=0.19.0 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (0.19.0)
Requirement already satisfied: bech32>=1.2.0 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (1.2.0)
Requirement already satisfied: cachetools>=5.3.0 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (5.3.1)
Requirement already satisfied: cryptography>=40.0.2 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (41.0.1)
Requirement already satisfied: prompt_toolkit>=3.0.38 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 7)) (3.0.38)
Collecting psycopg2>=2.9.6
  Using cached psycopg2-2.9.6.tar.gz (383 kB)
Collecting secp256k1>=0.14.0
  Using cached secp256k1-0.14.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.4 MB)
Collecting setuptools>=59.6.0
  Using cached setuptools-68.0.0-py3-none-any.whl (804 kB)
Collecting toml>=0.10.2
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: frozenlist>=1.1.1 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (1.3.3)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (4.0.2)
Requirement already satisfied: aiosignal>=1.1.2 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (1.3.1)
Requirement already satisfied: yarl<2.0,>=1.0 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (1.9.2)
Requirement already satisfied: multidict<7.0,>=4.5 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (6.0.4)
Requirement already satisfied: attrs>=17.3.0 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (23.1.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->-r requirements.txt (line 2)) (3.1.0)
Requirement already satisfied: cffi>=1.12 in ./venv/lib/python3.8/site-packages (from cryptography>=40.0.2->-r requirements.txt (line 6)) (1.15.1)
Requirement already satisfied: wcwidth in ./venv/lib/python3.8/site-packages (from prompt_toolkit>=3.0.38->-r requirements.txt (line 7)) (0.2.6)
Requirement already satisfied: idna>=2.0 in ./venv/lib/python3.8/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.4->-r requirements.txt (line 2)) (3.4)
Requirement already satisfied: pycparser in ./venv/lib/python3.8/site-packages (from cffi>=1.12->cryptography>=40.0.2->-r requirements.txt (line 6)) (2.21)
Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_sknndmb/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_sknndmb/psycopg2/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-7sa682ph
       cwd: /tmp/pip-install-_sknndmb/psycopg2/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
  Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2, secp256k1, setuptools, toml
    Running setup.py install for psycopg2 ... error
    ERROR: Command errored out with exit status 1:
     command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_sknndmb/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_sknndmb/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-vo8x3ke1/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/c/www/nostr/monstr_terminal/venv/include/site/python3.8/psycopg2
         cwd: /tmp/pip-install-_sknndmb/psycopg2/
    Complete output (38 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/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
    copying lib/_json.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.9.6 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120015 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/mnt/c/www/nostr/monstr_terminal/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -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:35:10: fatal error: Python.h: No such file or directory
       35 | #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 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_sknndmb/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_sknndmb/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-vo8x3ke1/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/c/www/nostr/monstr_terminal/venv/include/site/python3.8/psycopg2 Check the logs for full command output.

Really not sure how to proceed now.

arkin0x commented 1 year ago

I tried this: https://stackoverflow.com/a/51127206

python3 -m venv .
. bin/activate
pip install wheel (never had to do this on, say, Arch Linux)
pip install Flask

Did not help.

I then found this: https://stackoverflow.com/a/63887705

I realized that psycopg2 is part of the requirements.txt file. Since I already installed the binary, I removed it from requirements.txt and retried pip install -r requirements.txt. This time, it finished successfully.

I then ran into similar errors when trying to run pip install ./monstr. I tried removing psycopg2 from the ./monstr/requirements.txt file but it had no effect. Here is the output:

/mnt/c/www/nostr/monstr_terminal# pip install ./monstr
Processing ./monstr
Requirement already satisfied: aioconsole>=0.6.0 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (0.6.1)
Requirement already satisfied: aiohttp>=3.8.4 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (3.8.4)
Requirement already satisfied: aiosqlite>=0.18.0 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (0.19.0)
Requirement already satisfied: bech32>=1.2.0 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (1.2.0)
Requirement already satisfied: cachetools>=5.3.0 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (5.3.1)
Requirement already satisfied: cryptography>=39.0.1 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (41.0.1)

Collecting psycopg2>=2.9.6
  Using cached psycopg2-2.9.6.tar.gz (383 kB)
Requirement already satisfied: secp256k1>=0.14.0 in ./venv/lib/python3.8/site-packages (from monstr==0.1.2) (0.14.0)
Requirement already satisfied: aiosignal>=1.1.2 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (1.3.1)
Requirement already satisfied: yarl<2.0,>=1.0 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (1.9.2)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (4.0.2)
Requirement already satisfied: frozenlist>=1.1.1 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (1.3.3)
Requirement already satisfied: attrs>=17.3.0 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (23.1.0)
Requirement already satisfied: multidict<7.0,>=4.5 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (6.0.4)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./venv/lib/python3.8/site-packages (from aiohttp>=3.8.4->monstr==0.1.2) (3.1.0)
Requirement already satisfied: cffi>=1.12 in ./venv/lib/python3.8/site-packages (from cryptography>=39.0.1->monstr==0.1.2) (1.15.1)
Requirement already satisfied: idna>=2.0 in ./venv/lib/python3.8/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.4->monstr==0.1.2) (3.4)
Requirement already satisfied: pycparser in ./venv/lib/python3.8/site-packages (from cffi>=1.12->cryptography>=39.0.1->monstr==0.1.2) (2.21)
Building wheels for collected packages: monstr, psycopg2
  Building wheel for monstr (setup.py) ... done
  Created wheel for monstr: filename=monstr-0.1.2-py3-none-any.whl size=89858 sha256=94f4bd944c07cf40a02efdec3346a2b379a5584ca24c5f45ac47d7459de5c47f
  Stored in directory: /tmp/pip-ephem-wheel-cache-e_3qk9je/wheels/7f/bc/5e/a0832f2c39102a5c2257b69b1d8d593dcf823c8c630ec70e01
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jvmxi2il/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jvmxi2il/psycopg2/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-3atw8ji_
       cwd: /tmp/pip-install-jvmxi2il/psycopg2/
  Complete output (52 lines):
  /mnt/c/www/nostr/monstr_terminal/venv/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
  !!

          ********************************************************************************
          The license_file parameter is deprecated, use license_files instead.

          By 2023-Oct-30, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.

          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************

  !!
    parsed = self.parsers.get(option_name, lambda x: x)(value)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-cpython-38
  creating build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/errorcodes.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/pool.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/errors.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/sql.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/tz.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/_range.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/extensions.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/__init__.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/extras.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/_ipaddress.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  copying lib/_json.py -> build/lib.linux-x86_64-cpython-38/psycopg2
  running build_ext
  building 'psycopg2._psycopg' extension
  creating build/temp.linux-x86_64-cpython-38
  creating build/temp.linux-x86_64-cpython-38/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 -fPIC "-DPSYCOPG_VERSION=2.9.6 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120015 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/mnt/c/www/nostr/monstr_terminal/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-38/psycopg/adapter_asis.o -Wdeclaration-after-statement
  In file included from psycopg/adapter_asis.c:28:
  ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory
     35 | #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 '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
  Running setup.py clean for psycopg2
Successfully built monstr
Failed to build psycopg2
Installing collected packages: psycopg2, monstr
    Running setup.py install for psycopg2 ... error
    ERROR: Command errored out with exit status 1:
     command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jvmxi2il/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jvmxi2il/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-zktx0u42/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/c/www/nostr/monstr_terminal/venv/include/site/python3.8/psycopg2
         cwd: /tmp/pip-install-jvmxi2il/psycopg2/
    Complete output (65 lines):
    /mnt/c/www/nostr/monstr_terminal/venv/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
    !!

            ********************************************************************************
            The license_file parameter is deprecated, use license_files instead.

            By 2023-Oct-30, you need to update your project and remove deprecated calls
            or your builds will no longer be supported.

            See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
            ********************************************************************************

    !!
      parsed = self.parsers.get(option_name, lambda x: x)(value)
    running install
    /mnt/c/www/nostr/monstr_terminal/venv/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
    !!

            ********************************************************************************
            Please avoid running ``setup.py`` directly.
            Instead, use pypa/build, pypa/installer or other
            standards-based tools.

            See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
            ********************************************************************************

    !!
      self.initialize_options()
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-cpython-38
    creating build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/errorcodes.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/pool.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/errors.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/sql.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/tz.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/_range.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/extensions.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/__init__.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/extras.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/_ipaddress.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    copying lib/_json.py -> build/lib.linux-x86_64-cpython-38/psycopg2
    running build_ext
    building 'psycopg2._psycopg' extension
    creating build/temp.linux-x86_64-cpython-38
    creating build/temp.linux-x86_64-cpython-38/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 -fPIC "-DPSYCOPG_VERSION=2.9.6 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120015 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/mnt/c/www/nostr/monstr_terminal/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-38/psycopg/adapter_asis.o -Wdeclaration-after-statement
    In file included from psycopg/adapter_asis.c:28:
    ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory
       35 | #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 '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jvmxi2il/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jvmxi2il/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-zktx0u42/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/c/www/nostr/monstr_terminal/venv/include/site/python3.8/psycopg2 Check the logs for full command output.
monty888 commented 1 year ago

Hi, Is it because it uses the setup.py rather than requirements.txt? Maybe you could try removing psycopg2 from there and doing the pip install.

FYI psycopg2 is only used if setting postgres as relay.

Sent from ProtonMail mobile

-------- Original Message -------- On 29 Jun 2023, 22:39, arkin0x wrote:

I tried this: https://stackoverflow.com/a/51127206

python3 -m venv . . bin/activate pip install wheel (never had to do this on, say, Arch Linux) pip install Flask

Did not help.

I then found this: https://stackoverflow.com/a/63887705

I realized that psycopg2 is part of the requirements.txt file. Since I already installed the binary, I removed it from requirements.txt and retried pip install -r requirements.txt. This time, it finished successfully.

I then ran into similar errors when trying to run pip install ./monstr. I tried removing psycopg2 from the ./monstr/requirements.txt file but it had no effect. Here is the output:

/mnt/c/www/nostr/monstr_terminal# pip install ./monstr Processing ./monstr Requirement already satisfied: aioconsole

=0.6.0

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (0.6.1) Requirement already satisfied: aiohttp

=3.8.4

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (3.8.4) Requirement already satisfied: aiosqlite

=0.18.0

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (0.19.0) Requirement already satisfied: bech

32>

=1.2.0

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (1.2.0) Requirement already satisfied: cachetools

=5.3.0

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (5.3.1) Requirement already satisfied: cryptography

=39.0.1

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (41.0.1)

Collecting psycopg

2>

=2.9.6 Using cached psycopg2-2.9.6.tar.gz (383 kB) Requirement already satisfied: secp256k

1>

=0.14.0

in

./venv/lib/python3.8/site-packages (from monstr==0.1.2) (0.14.0) Requirement already satisfied: aiosignal

=1.1.2

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (1.3.1) Requirement already satisfied: yarl

<

2.0,

=1.0

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (1.9.2) Requirement already satisfied: async-timeout

<

5.0,

=4.0.0a3

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (4.0.2) Requirement already satisfied: frozenlist

=1.1.1

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (1.3.3) Requirement already satisfied: attrs

=17.3.0

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (23.1.0) Requirement already satisfied: multidict

<

7.0,

=4.5

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (6.0.4) Requirement already satisfied: charset-normalizer

<

4.0,

=2.0

in

./venv/lib/python3.8/site-packages (from aiohttp

=3.8.4-

monstr==0.1.2) (3.1.0) Requirement already satisfied: cffi

=1.12

in

./venv/lib/python3.8/site-packages (from cryptography

=39.0.1-

monstr==0.1.2) (1.15.1) Requirement already satisfied: idna

=2.0

in

./venv/lib/python3.8/site-packages (from yarl

<

2.0,

=1.0-

aiohttp

=3.8.4-

monstr==0.1.2) (3.4) Requirement already satisfied: pycparser

in

./venv/lib/python3.8/site-packages (from cffi

=1.12-

cryptography

=39.0.1-

monstr==0.1.2) (2.21) Building wheels

for

collected packages: monstr, psycopg2 Building wheel

for

monstr (setup.py) ...

done

Created wheel

for

monstr: filename=monstr-0.1.2-py3-none-any.whl size=89858 sha256=94f4bd944c07cf40a02efdec3346a2b379a5584ca24c5f45ac47d7459de5c47f Stored

in

directory: /tmp/pip-ephem-wheel-cache-e_3qk9je/wheels/7f/bc/5e/a0832f2c39102a5c2257b69b1d8d593dcf823c8c630ec70e01 Building wheel

for

psycopg2 (setup.py) ... error ERROR: Command errored out with

exit

status 1: command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c

'

import sys, setuptools, tokenize; sys.argv[0] =

'

"

'

"

'

/tmp/pip-install-jvmxi2il/psycopg2/setup.py

'

"

'

"

'

; file=

'

"

'

"

'

/tmp/pip-install-jvmxi2il/psycopg2/setup.py

'

"

'

"

'

;f=getattr(tokenize,

'

"

'

"

'

open

'

"

'

"

'

, open)(file);code=f.read().replace(

'

"

'

"

'

\r\n

'

"

'

"

'

,

'

"

'

"

'

\n

'

"

'

"

'

);f.close();exec(compile(code, file,

'

"

'

"

'

exec

'

"

'

"

'

))

'

bdistwheel -d /tmp/pip-wheel-3atw8ji cwd: /tmp/pip-install-jvmxi2il/psycopg2/ Complete output (52 lines): /mnt/c/www/nostr/monstr_terminal/venv/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config

in

`

setup.cfg

`

!!


The license_file parameter is deprecated, use license_files instead.

      By 2023-Oct-30, you need to update your project and remove deprecated calls
      or your builds will no longer be supported.

      See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html

for

details.


!!

parsed = self.parsers.get(option_name, lambda x: x)(value) running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-38 creating build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/errorcodes.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/pool.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/errors.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/sql.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/tz.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/_range.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/extensions.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/init.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/extras.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/_ipaddress.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/_json.py -

build/lib.linux-x86_64-cpython-38/psycopg2 running build_ext building

'

psycopg2._psycopg

'

extension creating build/temp.linux-x86_64-cpython-38 creating build/temp.linux-x86_64-cpython-38/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 -fPIC

"

-DPSYCOPG_VERSION=2.9.6 (dt dec pq3 ext lo64)

"

-DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120015 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/mnt/c/www/nostr/monstr_terminal/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-38/psycopg/adapter_asis.o -Wdeclaration-after-statement In file included from psycopg/adapter_asis.c:28: ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory 35

|

#

include

|

^~~~~~ 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

'

/usr/bin/x86_64-linux-gnu-gcc

'

failed with

exit

code 1

ERROR: Failed building wheel

for

psycopg2 Running setup.py clean

for

psycopg2 Successfully built monstr Failed to build psycopg2 Installing collected packages: psycopg2, monstr Running setup.py install

for

psycopg2 ... error ERROR: Command errored out with

exit

status 1: command: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c

'

import sys, setuptools, tokenize; sys.argv[0] =

'

"

'

"

'

/tmp/pip-install-jvmxi2il/psycopg2/setup.py

'

"

'

"

'

; file=

'

"

'

"

'

/tmp/pip-install-jvmxi2il/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-zktx0u42/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/c/www/nostr/monstr_terminal/venv/include/site/python3.8/psycopg2 cwd: /tmp/pip-install-jvmxi2il/psycopg2/ Complete output (65 lines): /mnt/c/www/nostr/monstr_terminal/venv/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config

in

`

setup.cfg

`

!!


The license_file parameter is deprecated, use license_files instead.

        By 2023-Oct-30, you need to update your project and remove deprecated calls
        or your builds will no longer be supported.

        See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html

for

details.


!!

parsed = self.parsers.get(option_name, lambda x: x)(value) running install /mnt/c/www/nostr/monstr_terminal/venv/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.

!!


Please avoid running

`

`

setup.py

`

`

directly. Instead, use pypa/build, pypa/installer or other standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html

for

details.


!!

self.initialize_options

() running build running build_py creating build creating build/lib.linux-x86_64-cpython-38 creating build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/errorcodes.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/pool.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/errors.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/sql.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/tz.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/_range.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/extensions.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/init.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/extras.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/_ipaddress.py -

build/lib.linux-x86_64-cpython-38/psycopg2 copying lib/_json.py -

build/lib.linux-x86_64-cpython-38/psycopg2 running build_ext building

'

psycopg2._psycopg

'

extension creating build/temp.linux-x86_64-cpython-38 creating build/temp.linux-x86_64-cpython-38/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 -fPIC

"

-DPSYCOPG_VERSION=2.9.6 (dt dec pq3 ext lo64)

"

-DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120015 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/mnt/c/www/nostr/monstr_terminal/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-38/psycopg/adapter_asis.o -Wdeclaration-after-statement In file included from psycopg/adapter_asis.c:28: ./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory 35

|

#

include

|

^~~~~~ 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

'

/usr/bin/x86_64-linux-gnu-gcc

'

failed with

exit

code 1

ERROR: Command errored out with

exit

status 1: /mnt/c/www/nostr/monstr_terminal/venv/bin/python3 -u -c

'

import sys, setuptools, tokenize; sys.argv[0] =

'

"

'

"

'

/tmp/pip-install-jvmxi2il/psycopg2/setup.py

'

"

'

"

'

; file=

'

"

'

"

'

/tmp/pip-install-jvmxi2il/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-zktx0u42/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/c/www/nostr/monstr_terminal/venv/include/site/python3.8/psycopg2 Check the logs

for

full

command

output.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

monty888 commented 1 year ago

psycopg2 is no longer part of the requirements so isn't installed unless done separately so this probably wouldnt be a problem anymore