tox refuses to use deps setting in py38 and various pip problems - python

I have a Django project that i'm trying to set up unit testing with tox in.
here is the directory structure:
+ djangoProject
|
+-.github
+-.pytest
+-.tox
+- api
+- blog
+- djangoProject
+- templates
|
+ .gitignore
+ manage.py
+ pyproject.toml
+ requirements.txt
+ requirements_dev.txt
+ setup.cfg
+ tox.ini
Here are the various config files
tox.ini:
[tox]
minversion = 3.8.0
envlist = py38, py39, py310, flake8
isolated_build = true
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
commands =
pytest --basetemp={envtmpdir}
[testenv:flake8]
basepython = python3.8
deps = flake8
commands = flake8
pyproject.toml:
[build-system]
requires = ["setuptools>=42.0", "wheel"]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
testpaths = [
"api",
"blog",
"djangoProject"
]
DJANGO_SETTINGS_MODULE = "djangoProject.settings"
python_files = "tests.py test_*.py *_tests.py"
setup.cfg:
[options]
packages =
api
blog
djangoProject
templates
[flake8]
max-line-length = 210
exclude =
.git,
.github,
.pytest_cache,
__pycache__,
docs/source/conf.py,
old,
build,
dist,
venv,
migrations
requirements_dev.txt:
Django~=4.0.3
djangorestframework~=3.13.1
django-gravatar2~=1.4.4
psycopg2~=2.9.3
beautifulsoup4~=4.10.0
pytest-django~=4.5.2
tox~=3.24.5
flake8~=4.0.1
I'm developing on Pycharm and Linux Mint 20.3 (in a HyperV VM)
Here is the output when I try to run tox:
(venv) dafrandle#linux-mint-VM:\~/PycharmProjects/djangoProject$ tox
py38 inst-nodeps: /home/dafrandle/PycharmProjects/djangoProject/.tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz
ERROR: invocation failed (exit code 1), logfile: /home/dafrandle/PycharmProjects/djangoProject/.tox/py38/log/py38-10.log
=============================================================================================================== log start ===============================================================================================================
Processing ./.tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─\> \[6 lines of output\]
No parent package detected, impossible to derive `name`
running egg_info
writing UNKNOWN.egg-info/PKG-INFO
writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
writing top-level names to UNKNOWN.egg-info/top_level.txt
error: package directory 'templates' does not exist
\[end of output\]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─\> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
================================================================================================================ log end ================================================================================================================
py39 create: /home/dafrandle/PycharmProjects/djangoProject/.tox/py39
py39 installdeps: -r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt
ERROR: invocation failed (exit code 1), logfile: /home/dafrandle/PycharmProjects/djangoProject/.tox/py39/log/py39-1.log
=============================================================================================================== log start ===============================================================================================================
Collecting Django\~=4.0.3
Using cached Django-4.0.3-py3-none-any.whl (8.0 MB)
Collecting djangorestframework\~=3.13.1
Using cached djangorestframework-3.13.1-py3-none-any.whl (958 kB)
Collecting django-gravatar2\~=1.4.4
Using cached django_gravatar2-1.4.4-py2.py3-none-any.whl (7.9 kB)
Collecting psycopg2\~=2.9.3
Using cached psycopg2-2.9.3.tar.gz (380 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting beautifulsoup4\~=4.10.0
Using cached beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
Collecting pytest-django\~=4.5.2
Using cached pytest_django-4.5.2-py3-none-any.whl (20 kB)
Collecting tox\~=3.24.5
Using cached tox-3.24.5-py2.py3-none-any.whl (85 kB)
Collecting flake8\~=4.0.1
Using cached flake8-4.0.1-py2.py3-none-any.whl (64 kB)
Collecting asgiref\<4,\>=3.4.1
Using cached asgiref-3.5.0-py3-none-any.whl (22 kB)
Collecting sqlparse\>=0.2.2
Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
Collecting pytz
Using cached pytz-2022.1-py2.py3-none-any.whl (503 kB)
Collecting soupsieve\>1.2
Using cached soupsieve-2.3.1-py3-none-any.whl (37 kB)
Collecting pytest\>=5.4.0
Using cached pytest-7.1.1-py3-none-any.whl (297 kB)
Collecting virtualenv!=20.0.0,!=20.0.1,!=20.0.2,!=20.0.3,!=20.0.4,!=20.0.5,!=20.0.6,!=20.0.7,\>=16.0.0
Using cached virtualenv-20.14.0-py2.py3-none-any.whl (8.8 MB)
Collecting six\>=1.14.0
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting toml\>=0.9.4
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting packaging\>=14
Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting py\>=1.4.17
Using cached py-1.11.0-py2.py3-none-any.whl (98 kB)
Collecting filelock\>=3.0.0
Using cached filelock-3.6.0-py3-none-any.whl (10.0 kB)
Collecting pluggy\>=0.12.0
Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting pycodestyle\<2.9.0,\>=2.8.0
Using cached pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
Collecting mccabe\<0.7.0,\>=0.6.0
Using cached mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pyflakes\<2.5.0,\>=2.4.0
Using cached pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)
Collecting pyparsing!=3.0.5,\>=2.0.2
Using cached pyparsing-3.0.7-py3-none-any.whl (98 kB)
Collecting tomli\>=1.0.0
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting iniconfig
Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting attrs\>=19.2.0
Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting distlib\<1,\>=0.3.1
Using cached distlib-0.3.4-py2.py3-none-any.whl (461 kB)
Collecting platformdirs\<3,\>=2
Using cached platformdirs-2.5.1-py3-none-any.whl (14 kB)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py): started
Building wheel for psycopg2 (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─\> \[38 lines of output\]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/psycopg2
copying lib/\_json.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/\_range.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/errors.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/\_ipaddress.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/extras.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/pool.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/__init__.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/errorcodes.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/tz.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/extensions.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/sql.py -\> build/lib.linux-x86_64-3.9/psycopg2
running build_ext
building 'psycopg2.\_psycopg' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/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 -fPIC "-DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120009 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/dafrandle/PycharmProjects/djangoProject/.tox/py39/include -I/usr/include/python3.9 -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-3.9/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
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: pytz, mccabe, iniconfig, django-gravatar2, distlib, tomli, toml, sqlparse, soupsieve, six, pyparsing, pyflakes, pycodestyle, py, psycopg2, pluggy, platformdirs, filelock, attrs, asgiref, virtualenv, packaging, flake8, Django, beautifulsoup4, tox, pytest, djangorestframework, pytest-django
Running setup.py install for psycopg2: started
Running setup.py install for psycopg2: finished with status 'error'
error: subprocess-exited-with-error
× Running setup.py install for psycopg2 did not run successfully.
│ exit code: 1
╰─\> \[40 lines of output\]
running install
/home/dafrandle/PycharmProjects/djangoProject/.tox/py39/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.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/psycopg2
copying lib/\_json.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/\_range.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/errors.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/\_ipaddress.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/extras.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/pool.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/__init__.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/errorcodes.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/tz.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/extensions.py -\> build/lib.linux-x86_64-3.9/psycopg2
copying lib/sql.py -\> build/lib.linux-x86_64-3.9/psycopg2
running build_ext
building 'psycopg2.\_psycopg' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/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 -fPIC "-DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120009 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/dafrandle/PycharmProjects/djangoProject/.tox/py39/include -I/usr/include/python3.9 -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-3.9/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
[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.
╰─\> psycopg2
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
================================================================================================================ log end ================================================================================================================
ERROR: could not install deps \[-r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt\]; v = InvocationError('/home/dafrandle/PycharmProjects/djangoProject/.tox/py39/bin/python -m pip install -r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt', 1)
py310 create: /home/dafrandle/PycharmProjects/djangoProject/.tox/py310
py310 installdeps: -r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt
ERROR: invocation failed (exit code 1), logfile: /home/dafrandle/PycharmProjects/djangoProject/.tox/py310/log/py310-1.log
=============================================================================================================== log start ===============================================================================================================
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in \_run_module_as_main
return \_run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in \_run_code
exec(code, run_globals)
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/__main__.py", line 29, in \<module\>
from pip.\_internal.cli.main import main as \_main
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/cli/main.py", line 9, in \<module\>
from pip.\_internal.cli.autocompletion import autocomplete
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/cli/autocompletion.py", line 10, in \<module\>
from pip.\_internal.cli.main_parser import create_main_parser
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/cli/main_parser.py", line 8, in \<module\>
from pip.\_internal.cli import cmdoptions
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/cli/cmdoptions.py", line 23, in \<module\>
from pip.\_internal.cli.parser import ConfigOptionParser
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/cli/parser.py", line 12, in \<module\>
from pip.\_internal.configuration import Configuration, ConfigurationError
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/configuration.py", line 26, in \<module\>
from pip.\_internal.utils.logging import getLogger
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/utils/logging.py", line 27, in \<module\>
from pip.\_internal.utils.misc import ensure_dir
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/utils/misc.py", line 39, in \<module\>
from pip.\_internal.locations import get_major_minor_version
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/locations/__init__.py", line 14, in \<module\>
from . import \_distutils, \_sysconfig
File "/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/lib/python3.10/site-packages/pip/\_internal/locations/\_distutils.py", line 9, in \<module\>
from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'
================================================================================================================ log end ================================================================================================================
ERROR: could not install deps \[-r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt\]; v = InvocationError('/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/bin/python -m pip install -r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt', 1)
flake8 inst-nodeps: /home/dafrandle/PycharmProjects/djangoProject/.tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz
ERROR: invocation failed (exit code 1), logfile: /home/dafrandle/PycharmProjects/djangoProject/.tox/flake8/log/flake8-7.log
=============================================================================================================== log start ===============================================================================================================
Processing ./.tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─\> \[6 lines of output\]
No parent package detected, impossible to derive `name`
running egg_info
writing UNKNOWN.egg-info/PKG-INFO
writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
writing top-level names to UNKNOWN.egg-info/top_level.txt
error: package directory 'templates' does not exist
\[end of output\]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─\> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
================================================================================================================ log end ================================================================================================================
\___\_ summary \___\_
ERROR: py38: InvocationError for command /home/dafrandle/PycharmProjects/djangoProject/.tox/py38/bin/python -m pip install --no-deps -U .tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz (exited with code 1)
ERROR: py39: could not install deps \[-r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt\]; v = InvocationError('/home/dafrandle/PycharmProjects/djangoProject/.tox/py39/bin/python -m pip install -r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt', 1)
ERROR: py310: could not install deps \[-r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt\]; v = InvocationError('/home/dafrandle/PycharmProjects/djangoProject/.tox/py310/bin/python -m pip install -r/home/dafrandle/PycharmProjects/djangoProject/requirements_dev.txt', 1)
ERROR: flake8: InvocationError for command /home/dafrandle/PycharmProjects/djangoProject/.tox/flake8/bin/python -m pip install --no-deps -U .tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz (exited with code 1)
their is multiple problems here
1: both py38 envs don't use my requirements and instead run pip with --no-deps and goes after some file that doesn't exist
2: in py38 envs the wheel fails to build - this is probably because of #1 but I'm not sure.
3: In all other envs the wheel for psycopg2 fails to build and it also fails to install using setup.py
I have tried removing lines from the tox.ini to get a different output to try and locate the issue if it was in the ini files but found nothing.
when I add things to my project with pip manually or using PyCharm's package manger inclduing psycopg2 it all works fine so I don't know why it wont work in tox
I don't know what I'm doing wrong
I was working off this tutorial video:
https://www.youtube.com/watch?v=DhUpxWjOhME
it's not for a Django project but everything before the tox part I was able to get running fine

This answer is an addendum to Jürgen's answer:
The cause of
py38 inst-nodeps: /home/dafrandle/PycharmProjects/djangoProject/.tox/.tmp/package/1/UNKNOWN-0.0.0.tar.gz
happening is because setuptools was treating my django apps (api, blog) as packages
I don't know exactly what it does then - if it passes them to pip, or dose something else, but they aren't setup to be packages, so it ends up doing the above.
I found this answer to a different question:
https://stackoverflow.com/a/26938095/17981284
that describes the situation for my project and applying the setting
skipsdist = True in my tox.ini resolves my issue

The problem is well described in the error log:
building 'psycopg2.\_psycopg' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/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 -fPIC "-DPSYCOPG_VERSION=2.9.3 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120009 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/dafrandle/PycharmProjects/djangoProject/.tox/py39/include -I/usr/include/python3.9 -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-3.9/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
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: pytz, mccabe, iniconfig, django-gravatar2, distlib, tomli, toml, sqlparse, soupsieve, six, pyparsing, pyflakes, pycodestyle, py, psycopg2, pluggy, platformdirs, filelock, attrs, asgiref, virtualenv, packaging, flake8, Django, beautifulsoup4, tox, pytest, djangorestframework, pytest-django
Running setup.py install for psycopg2: started
Running setup.py install for psycopg2: finished with status 'error'
error: subprocess-exited-with-error
× Running setup.py install for psycopg2 did not run successfully.
│ exit code: 1
╰─\> \[40 lines of output\]
So you fail to build the psycopg2 package, because...
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\>
... pip tries to install the source package, which needs some compilation step for this the mentioned header file is missing.
When I try to reproduce the issue...
pip install psycopg2
Collecting psycopg2
Downloading psycopg2-2.9.3.tar.gz (380 kB)
...
You clearly see, that psycopg2 is downloaded as source and not as wheel.
So this is not a tox issue, but rather the project does not provide a pre-compiled wheel, and your environment is missing the necessary requirements.
There is the question left why this would work in your PyCharm environment. This is nothing I can say for sure, but one possible issue could be that your PyCharm is running in a different environment than tox - as you mentioned you are working in a VM environment. So this is something you need to figure out yourself.

Related

I tried everything to install pyaudio on macOS Monterrey

I installed brew
Use brew install portaudio
I link with brew link portaudio
Installed pyaudio with pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
and I tried install with pip install pyaudio and pip3 install pyaudio
But unhappily I always have the same error
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AssertionError:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-cpython-310
copying src/pyaudio.py -> build/lib.macosx-12-arm64-cpython-310
running build_ext
building '_portaudio' extension
creating build/temp.macosx-12-arm64-cpython-310
creating build/temp.macosx-12-arm64-cpython-310/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DMACOSX=1 -I/usr/local/include -I/usr/include -I</opt/homebrew/opt/portaudi>include/ -I/opt/homebrew/opt/python#3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/_portaudiomodule.c -o build/temp.macosx-12-arm64-cpython-310/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
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 pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
I have the same issue as well, but following work-around worked for me.
Install portaudio
brew install portaudio
Link
brew link portaudio
Locate the library and includes
sudo find / -name "portaudio.h"
Use it with global options
pip3 install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include/' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib/' pyaudio
But this fails as you are pointing above. For some reason, it doesn't include the path for libs and include with build_ext option.
Downloading PyAudio-0.2.12.tar.gz (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.9/42.9 kB 1.6 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11.0-arm64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-11.0-arm64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-11.0-arm64-cpython-39
creating build/temp.macosx-11.0-arm64-cpython-39/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/koteshk/miniforge3/include -arch arm64 -fPIC -O2 -isystem /Users/koteshk/miniforge3/include -arch arm64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/koteshk/miniforge3/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-11.0-arm64-cpython-39/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
Work around
Manually copy the libs and include files to one of the system paths. Note you may have to create the directory if it's not present.
sudo cp -r /opt/homebrew/Cellar/portaudio/19.7.0/include/* /usr/local/include
sudo cp -r /opt/homebrew/Cellar/portaudio/19.7.0/lib/* /usr/local/lib
Install pyaudio
pip install pyaudio
OK, I solved my own problem. To solved this problem portaudio.h just follow the topics bellow.
Pyaudio for MACOS users --> Project with Speech Recognition
Install homebrew --> https://brew.sh/index_pt-br
brew install portaudio
brew link portaudio
type LDFLAGS="-L$(brew --prefix portaudio)/lib" CFLAGS="-I$(brew --prefix portaudio)/include" pip install pyaudio
brew install flac --> https://formulae.brew.sh/formula/flac
install speech_recognition with pip

Cannot for the life of me get portaudio install on my M1Pro Macbook Pro

sudo -H pip install pyaudio --global-option="build_ext" --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"
WARNING: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
Collecting pyaudio
Downloading PyAudio-0.2.12.tar.gz (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.9/42.9 kB 872.0 kB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-12-arm64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-12-arm64-cpython-39
creating build/temp.macosx-12-arm64-cpython-39/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DMACOSX=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/Cellar/python#3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-12-arm64-cpython-39/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
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 pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
When I run the command, no matter what - pip install pyaudio, or the above command with/without sudo it always gives the same error. I see this is a very common issue. I double checked the path and portaudio in the directory used in the command. I am at a loss and really do not understand why it is not working. I also tried building pyaudio directly from the file itself and it still doesn't work. Does anyone have any suggestions?
SOLVED: I found this: https://qiita.com/yukilab/items/d50a10f1d46c44ae0757
even though it is in another language I was able to get it working. It is similar to what was suggested by #Bob th but slightly different.
In essence I made a file .pydistutils.cfg and added
[build_ext]
include_dirs=/opt/homebrew/include
library_dirs=/opt/homebrew/lib

Cannot install web3py in Pycharm, linux machine

having problems installing web3 package in Pycharm. I am old and clueless when it comes to package installations. The same errors occur either through pip install or interpreter settings/add package. I do not know what else to try and stackoverflow is giving me an error because it says I need to add more details.
OS: Linux Mint 20.1
Pycharm: 2021.1.3
Python: 3.8.10
This answer worked:
"You have to install apt install python3.8-dev –
furas
"
Collecting web3
Using cached web3-5.28.0-py3-none-any.whl (499 kB)
Collecting eth-utils<2.0.0,>=1.9.5
Using cached eth_utils-1.10.0-py3-none-any.whl (24 kB)
Collecting aiohttp<4,>=3.7.4.post0
Using cached aiohttp-3.8.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.3 MB)
Collecting lru-dict<2.0.0,>=1.1.6
Using cached lru-dict-1.1.7.tar.gz (10 kB)
Preparing metadata (setup.py) ... done
Collecting hexbytes<1.0.0,>=0.1.0
Using cached hexbytes-0.2.2-py3-none-any.whl (6.1 kB)
Requirement already satisfied: requests<3.0.0,>=2.16.0 in /usr/lib/python3/dist-packages (from web3) (2.22.0)
Collecting eth-abi<3.0.0,>=2.0.0b6
Using cached eth_abi-2.1.1-py3-none-any.whl (27 kB)
Collecting ipfshttpclient==0.8.0a2
Using cached ipfshttpclient-0.8.0a2-py3-none-any.whl (82 kB)
Collecting eth-account<0.6.0,>=0.5.7
Using cached eth_account-0.5.7-py3-none-any.whl (101 kB)
Collecting jsonschema<4.0.0,>=3.2.0
Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Collecting protobuf<4,>=3.10.0
Using cached protobuf-3.19.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
Collecting eth-hash[pycryptodome]<1.0.0,>=0.2.0
Using cached eth_hash-0.3.2-py3-none-any.whl (8.8 kB)
Collecting eth-typing<3.0.0,>=2.0.0
Using cached eth_typing-2.3.0-py3-none-any.whl (6.2 kB)
Collecting websockets<10,>=9.1
Using cached websockets-9.1-cp38-cp38-manylinux2010_x86_64.whl (102 kB)
Collecting multiaddr>=0.0.7
Using cached multiaddr-0.0.9-py2.py3-none-any.whl (16 kB)
Collecting attrs>=17.3.0
Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting frozenlist>=1.1.1
Using cached frozenlist-1.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (158 kB)
Collecting async-timeout<5.0,>=4.0.0a3
Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting yarl<2.0,>=1.0
Using cached yarl-1.7.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (308 kB)
Collecting charset-normalizer<3.0,>=2.0
Using cached charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting aiosignal>=1.1.2
Using cached aiosignal-1.2.0-py3-none-any.whl (8.2 kB)
Collecting multidict<7.0,>=4.5
Using cached multidict-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (121 kB)
Collecting parsimonious<0.9.0,>=0.8.0
Using cached parsimonious-0.8.1-py3-none-any.whl
Collecting eth-rlp<2,>=0.1.2
Using cached eth_rlp-0.3.0-py3-none-any.whl (5.0 kB)
Collecting eth-keys<0.4.0,>=0.3.4
Using cached eth_keys-0.3.4-py3-none-any.whl (21 kB)
Collecting rlp<3,>=1.0.0
Using cached rlp-2.0.1-py2.py3-none-any.whl (20 kB)
Collecting bitarray<1.3.0,>=1.2.1
Using cached bitarray-1.2.2.tar.gz (48 kB)
Preparing metadata (setup.py) ... done
Collecting eth-keyfile<0.6.0,>=0.5.0
Using cached eth_keyfile-0.5.1-py3-none-any.whl (8.3 kB)
Collecting pycryptodome<4,>=3.6.6
Using cached pycryptodome-3.14.1-cp35-abi3-manylinux2010_x86_64.whl (2.0 MB)
Collecting cytoolz<1.0.0,>=0.10.1
Using cached cytoolz-0.11.2.tar.gz (481 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: six>=1.11.0 in /usr/lib/python3/dist-packages (from jsonschema<4.0.0,>=3.2.0->web3) (1.14.0)
Collecting pyrsistent>=0.14.0
Using cached pyrsistent-0.18.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (119 kB)
Requirement already satisfied: setuptools in ./venv/lib/python3.8/site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (60.9.3)
Requirement already satisfied: toolz>=0.8.0 in ./venv/lib/python3.8/site-packages (from cytoolz<1.0.0,>=0.10.1->eth-utils<2.0.0,>=1.9.5->web3) (0.11.2)
Collecting eth-rlp<2,>=0.1.2
Using cached eth_rlp-0.2.1-py3-none-any.whl (5.0 kB)
Requirement already satisfied: varint in ./venv/lib/python3.8/site-packages (from multiaddr>=0.0.7->ipfshttpclient==0.8.0a2->web3) (1.0.2)
Collecting base58
Using cached base58-2.1.1-py3-none-any.whl (5.6 kB)
Requirement already satisfied: netaddr in ./venv/lib/python3.8/site-packages (from multiaddr>=0.0.7->ipfshttpclient==0.8.0a2->web3) (0.8.0)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.0->aiohttp<4,>=3.7.4.post0->web3) (2.8)
Building wheels for collected packages: lru-dict, bitarray, cytoolz
Building wheel for lru-dict (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
running bdist_wheel
running build
running build_ext
building 'lru' extension
creating build
creating build/temp.linux-x86_64-3.8
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 -I/home/bs/PycharmProjects/SOLIDITY_TESTING/venv/include -I/usr/include/python3.8 -c lru.c -o build/temp.linux-x86_64-3.8/lru.o
lru.c:1:10: fatal error: Python.h: No such file or directory
1 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-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: Failed building wheel for lru-dict
Running setup.py clean for lru-dict
Building wheel for bitarray (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
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/bitarray
copying bitarray/test_bitarray.py -> build/lib.linux-x86_64-3.8/bitarray
copying bitarray/__init__.py -> build/lib.linux-x86_64-3.8/bitarray
copying bitarray/test_util.py -> build/lib.linux-x86_64-3.8/bitarray
copying bitarray/util.py -> build/lib.linux-x86_64-3.8/bitarray
running build_ext
building 'bitarray._bitarray' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/bitarray
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 -I/home/bs/PycharmProjects/SOLIDITY_TESTING/venv/include -I/usr/include/python3.8 -c bitarray/_bitarray.c -o build/temp.linux-x86_64-3.8/bitarray/_bitarray.o
bitarray/_bitarray.c:12:10: fatal error: Python.h: No such file or directory
12 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-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: Failed building wheel for bitarray
Running setup.py clean for bitarray
Building wheel for cytoolz (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [60 lines of output]
[1/5] Cythonizing cytoolz/utils.pyx
[2/5] Cythonizing cytoolz/dicttoolz.pyx
[3/5] Cythonizing cytoolz/functoolz.pyx
[4/5] Cythonizing cytoolz/itertoolz.pyx
[5/5] Cythonizing cytoolz/recipes.pyx
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/cytoolz
copying cytoolz/_version.py -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/__init__.py -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/_signatures.py -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/compatibility.py -> build/lib.linux-x86_64-3.8/cytoolz
creating build/lib.linux-x86_64-3.8/cytoolz/curried
copying cytoolz/curried/exceptions.py -> build/lib.linux-x86_64-3.8/cytoolz/curried
copying cytoolz/curried/__init__.py -> build/lib.linux-x86_64-3.8/cytoolz/curried
copying cytoolz/curried/operator.py -> build/lib.linux-x86_64-3.8/cytoolz/curried
copying cytoolz/dicttoolz.pyx -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/utils.pyx -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/recipes.pyx -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/itertoolz.pyx -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/functoolz.pyx -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/itertoolz.pxd -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/dicttoolz.pxd -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/utils.pxd -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/recipes.pxd -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/cpython.pxd -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/functoolz.pxd -> build/lib.linux-x86_64-3.8/cytoolz
copying cytoolz/__init__.pxd -> build/lib.linux-x86_64-3.8/cytoolz
creating build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_curried_toolzlike.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_serialization.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_functoolz.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_docstrings.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_recipes.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_dicttoolz.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_curried.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_dev_skip_test.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_utils.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_inspect_args.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_itertoolz.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_compatibility.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_signatures.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_none_safe.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_embedded_sigs.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/dev_skip_test.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_doctests.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
copying cytoolz/tests/test_tlz.py -> build/lib.linux-x86_64-3.8/cytoolz/tests
running build_ext
building 'cytoolz.dicttoolz' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/cytoolz
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 -I/home/bs/PycharmProjects/SOLIDITY_TESTING/venv/include -I/usr/include/python3.8 -c cytoolz/dicttoolz.c -o build/temp.linux-x86_64-3.8/cytoolz/dicttoolz.o
cytoolz/dicttoolz.c:19:10: fatal error: Python.h: No such file or directory
19 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-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: Failed building wheel for cytoolz
Running setup.py clean for cytoolz
Failed to build lru-dict bitarray cytoolz
Installing collected packages: lru-dict, bitarray, websockets, pyrsistent, pycryptodome, protobuf, parsimonious, multidict, hexbytes, frozenlist, eth-typing, eth-hash, cytoolz, charset-normalizer, base58, attrs, async-timeout, yarl, multiaddr, jsonschema, eth-utils, aiosignal, rlp, ipfshttpclient, eth-keys, eth-abi, aiohttp, eth-rlp, eth-keyfile, eth-account, web3
Running setup.py install for lru-dict ... error
error: subprocess-exited-with-error
× Running setup.py install for lru-dict did not run successfully.
│ exit code: 1
╰─> [14 lines of output]
running install
/home/bs/PycharmProjects/SOLIDITY_TESTING/venv/lib/python3.8/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_ext
building 'lru' extension
creating build
creating build/temp.linux-x86_64-3.8
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 -I/home/bs/PycharmProjects/SOLIDITY_TESTING/venv/include -I/usr/include/python3.8 -c lru.c -o build/temp.linux-x86_64-3.8/lru.o
lru.c:1:10: fatal error: Python.h: No such file or directory
1 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-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.
╰─> lru-dict
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
In error you can see
Python.h: No such file or directory
and it means it compiles some C/C++ code and it needs C/C++ headers for Python source code.
You have to install
apt install python3.8-dev

Docker python:3.9.10-slim-buster image can not install backports.zoneinfo using pip

I have tried Containerising an django project. I was using python:alpine image. The app needed backports.zoneinfo to be installed as requirement. While running pip install -r requirements.txt its showing error when it try to install the backports.zoneinfo.
requirements.txt
asgiref==3.5.0
backports.zoneinfo==0.2.1
Django==4.0.2
sqlparse==0.4.2
Then I have opened docker container in interactive mode and tried pip install backports.zoneinfo. There also its showing same error.
I have tried the same commands in python:3.9.10 image. It was working fine and the package got installed. This error can be reproduced using any of slim, alpine images.
I have went through couple of fixes. But it wasn't working. Few of the fixes that I have tried are given below. I have tried these inside the container.
pip upgrade
pip upgrade wheel
apt/apk install gcc
apt/apk install gzdata
pip install python-dev-tools
apt/apk install gcc-c++
To reproduce the error
Command
docker pull python:alpine
docker run -it python:alpine sh
pip install backports.zoneinfo
Error
Collecting backports.zoneinfo
Downloading backports.zoneinfo-0.2.1.tar.gz (74 kB)
|████████████████████████████████| 74 kB 692 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: backports.zoneinfo
Building wheel for backports.zoneinfo (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmprpnblifv
cwd: /tmp/pip-install-tese9bhy/backports-zoneinfo_cf483b65d8814b8c8a8db93a7369c0cf
Complete output (35 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/backports
copying src/backports/__init__.py -> build/lib.linux-x86_64-3.9/backports
creating build/lib.linux-x86_64-3.9/backports/zoneinfo
copying src/backports/zoneinfo/_tzpath.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
copying src/backports/zoneinfo/_zoneinfo.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
copying src/backports/zoneinfo/_common.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
copying src/backports/zoneinfo/__init__.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
copying src/backports/zoneinfo/_version.py -> build/lib.linux-x86_64-3.9/backports/zoneinfo
running egg_info
writing src/backports.zoneinfo.egg-info/PKG-INFO
writing dependency_links to src/backports.zoneinfo.egg-info/dependency_links.txt
writing requirements to src/backports.zoneinfo.egg-info/requires.txt
writing top-level names to src/backports.zoneinfo.egg-info/top_level.txt
reading manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.png' under directory 'docs'
warning: no files found matching '*.svg' under directory 'docs'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_output'
adding license file 'LICENSE'
adding license file 'licenses/LICENSE_APACHE'
writing manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
copying src/backports/zoneinfo/__init__.pyi -> build/lib.linux-x86_64-3.9/backports/zoneinfo
copying src/backports/zoneinfo/py.typed -> build/lib.linux-x86_64-3.9/backports/zoneinfo
running build_ext
building 'backports.zoneinfo._czoneinfo' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/lib
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.9 -c lib/zoneinfo_module.c -o build/temp.linux-x86_64-3.9/lib/zoneinfo_module.o -std=c99
error: command 'gcc' failed: No such file or directory
----------------------------------------
ERROR: Failed building wheel for backports.zoneinfo
ERROR: Could not build wheels for backports.zoneinfo which use PEP 517 and cannot be installed directly
It's complaining about a missing file or directory. It's a bit misleading since it's gcc that's missing. In alpine, you'll also have to install musl-dev, too, to get all the required development files.
apk add -u gcc musl-dev
Also, python:alpine3.15 is using python3.10 which doesn't seem to be supported by backports.zoneinfo. https://github.com/pganssle/zoneinfo/issues/111

Why am I getting an error while installing discord.py on mac

QUICK NOTE: This question is probably more related to macos or zsh than python.
I am trying to install discord.py on macos monterey, though I have the xcode command line tools, I am facing errors while installing discord.py. I am running Python 3.11.0a5.
The whole output:
Collecting discord.py
Using cached discord.py-1.7.3-py3-none-any.whl (786 kB)
Collecting aiohttp<3.8.0,>=3.6.0
Using cached aiohttp-3.7.4.post0-py3-none-any.whl
Collecting yarl<2.0,>=1.0
Using cached yarl-1.7.2.tar.gz (168 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting async-timeout<4.0,>=3.0
Using cached async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Collecting chardet<5.0,>=2.0
Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting typing-extensions>=3.6.5
Using cached typing_extensions-4.1.1-py3-none-any.whl (26 kB)
Collecting multidict<7.0,>=4.5
Using cached multidict-6.0.2-cp311-cp311-macosx_10_9_universal2.whl
Collecting attrs>=17.3.0
Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting idna>=2.0
Using cached idna-3.3-py3-none-any.whl (61 kB)
Building wheels for collected packages: yarl
Building wheel for yarl (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for yarl (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [43 lines of output]
**********************
* Accelerated build *
**********************
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-3.11
creating build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/_url.py -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/_quoting_py.py -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/__init__.py -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/_quoting.py -> build/lib.macosx-10.9-universal2-3.11/yarl
running egg_info
writing yarl.egg-info/PKG-INFO
writing dependency_links to yarl.egg-info/dependency_links.txt
writing requirements to yarl.egg-info/requires.txt
writing top-level names to yarl.egg-info/top_level.txt
reading manifest file 'yarl.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.cache' found anywhere in distribution
warning: no previously-included files found matching 'yarl/*.html'
warning: no previously-included files found matching 'yarl/*.so'
warning: no previously-included files found matching 'yarl/*.pyd'
no previously-included directories found matching 'docs/_build'
adding license file 'LICENSE'
writing manifest file 'yarl.egg-info/SOURCES.txt'
copying yarl/__init__.pyi -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/_quoting_c.c -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/_quoting_c.pyi -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/_quoting_c.pyx -> build/lib.macosx-10.9-universal2-3.11/yarl
copying yarl/py.typed -> build/lib.macosx-10.9-universal2-3.11/yarl
running build_ext
building 'yarl._quoting_c' extension
creating build/temp.macosx-10.9-universal2-3.11
creating build/temp.macosx-10.9-universal2-3.11/yarl
clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c yarl/_quoting_c.c -o build/temp.macosx-10.9-universal2-3.11/yarl/_quoting_c.o
yarl/_quoting_c.c:198:12: fatal error: 'longintrepr.h' file not found
#include "longintrepr.h"
^~~~~~~~~~~~~~~
1 error generated.
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 yarl
Failed to build yarl
ERROR: Could not build wheels for yarl, which is required to install pyproject.toml-based projects
https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting
You're getting an error because you're using an alpha release of Python 3.11 and YARL hasn't been updated to support it yet.
The non-limited API files cellobject.h, classobject.h, code.h, context.h, funcobject.h, genobject.h and longintrepr.h have been moved to the Include/cpython directory. Moreover, the eval.h header file was removed. These files must not be included directly, as they are already included in Python.h: Include Files. If they have been included directly, consider including Python.h instead. (Contributed by Victor Stinner in bpo-35134.)
You should use a supported version of Python 3.10.
Try upgrading it:
pip install -U yarl

Categories