Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda Install Issue with httpx Dependency #856

Open
jeff-ws opened this issue May 15, 2024 · 1 comment
Open

Conda Install Issue with httpx Dependency #856

jeff-ws opened this issue May 15, 2024 · 1 comment

Comments

@jeff-ws
Copy link

jeff-ws commented May 15, 2024

Hello-

I'm working on a project that uses pyam and IamDataFrame and I'm having trouble getting a reliable install with conda.

The demo below shows the .yml file used to make a simple environment with only pyam included and the 1-liner import fails with the shown error trace. I'm running on MacOS.

Am I missing something or ? I'm not a regular conda user, but this project requires it.

conda env file used to creat environment:

name: pyam_test
channels:
    - defaults
    - conda-forge
dependencies:
    - pyam

test file:

import pyam

print('hello')

t = pyam.IamDataFrame('test')

Error trace:

Traceback (most recent call last):
  File "/Users/jeff/PycharmProjects/pyam_test/main.py", line 5, in <module>
    import pyam
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/pyam/__init__.py", line 3, in <module>
    from pyam.core import (
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/pyam/core.py", line 9, in <module>
    import ixmp4
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/__init__.py", line 4, in <module>
    from ixmp4.core import Model as Model
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/core/__init__.py", line 2, in <module>
    from .iamc.variable import Variable as Variable
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/core/iamc/__init__.py", line 3, in <module>
    from .data import RunIamcData, PlatformIamcData
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/core/iamc/data.py", line 9, in <module>
    from ixmp4.data.backend import Backend
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/data/backend/__init__.py", line 3, in <module>
    from .api import RestBackend, RestTestBackend
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/data/backend/api.py", line 26, in <module>
    from ixmp4.server import app, v1
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/server/__init__.py", line 16, in <module>
    from .rest import v1
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/server/rest/__init__.py", line 11, in <module>
    from . import deps, docs, meta, model, region, run, scenario, unit
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/server/rest/deps.py", line 15, in <module>
    manager = ManagerConfig(
              ^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/ixmp4/conf/manager.py", line 54, in __init__
    self.client = httpx.Client(
                  ^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pyam_test/lib/python3.12/site-packages/httpx/_client.py", line 669, in __init__
    raise ImportError(
ImportError: Using http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.

The environment list:

(pyam_test) jeff@Jeffs-Mac-Studio pyam_test % conda list
# packages in environment at /opt/anaconda3/envs/pyam_test:
#
# Name                    Version                   Build  Channel
alembic                   1.13.1             pyhd8ed1ab_1    conda-forge
annotated-types           0.6.0           py312hca03da5_0  
anyio                     4.2.0           py312hca03da5_0  
argon2-cffi               21.3.0             pyhd3eb1b0_0  
argon2-cffi-bindings      21.2.0          py312h80987f9_0  
arrow                     1.2.3           py312hca03da5_1  
babel                     2.11.0          py312hca03da5_0  
bcrypt                    3.2.0           py312h80987f9_1  
blas                      1.0                    openblas  
bottleneck                1.3.7           py312ha86b861_0  
brotli                    1.0.9                h80987f9_8  
brotli-bin                1.0.9                h80987f9_8  
brotli-python             1.0.9           py312h313beb8_8  
bzip2                     1.0.8                h80987f9_6  
ca-certificates           2024.3.11            hca03da5_0  
certifi                   2024.2.2        py312hca03da5_0  
cffi                      1.16.0          py312h80987f9_1  
charset-normalizer        2.0.4              pyhd3eb1b0_0  
click                     8.1.7           py312hca03da5_0  
colorama                  0.4.6           py312hca03da5_0  
colour                    0.1.4              pyhd67b51d_0  
contourpy                 1.2.0           py312h48ca7d4_0  
cryptography              42.0.5          py312hd4332d6_1  
cycler                    0.11.0             pyhd3eb1b0_0  
et_xmlfile                1.1.0           py312hca03da5_1  
fastapi                   0.103.0         py312hca03da5_0  
fonttools                 4.51.0          py312h80987f9_0  
freetype                  2.12.1               h1192e45_0  
furl                      2.1.2              pyhd3eb1b0_0  
greenlet                  3.0.1           py312h313beb8_0  
h11                       0.14.0          py312hca03da5_0  
httpcore                  1.0.2           py312hca03da5_0  
httpx                     0.26.0          py312hca03da5_0  
iam-units                 2023.9.12          pyhd8ed1ab_0    conda-forge
idna                      3.7             py312hca03da5_0  
importlib-metadata        7.0.1           py312hca03da5_0  
importlib_resources       6.1.1           py312hca03da5_1  
infinity                  1.5                pyhd8ed1ab_0    conda-forge
intervals                 0.9.2              pyhd8ed1ab_0    conda-forge
ixmp4                     0.8.3              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h80987f9_1  
kiwisolver                1.4.4           py312h313beb8_0  
krb5                      1.21.2               h92f50d5_0    conda-forge
lcms2                     2.12                 hba8e193_0  
lerc                      3.0                  hc377ac9_0  
libbrotlicommon           1.0.9                h80987f9_8  
libbrotlidec              1.0.9                h80987f9_8  
libbrotlienc              1.0.9                h80987f9_8  
libcxx                    17.0.6               h5f092b4_0    conda-forge
libdeflate                1.17                 h80987f9_1  
libedit                   3.1.20230828         h80987f9_0  
libexpat                  2.6.2                hebf3989_0    conda-forge
libffi                    3.4.4                hca03da5_1  
libgfortran               5.0.0           11_3_0_hca03da5_28  
libgfortran5              11.3.0              h009349e_28  
libopenblas               0.3.21               h269037a_0  
libpng                    1.6.39               h80987f9_0  
libpq                     16.3                 h7afe498_0    conda-forge
libsqlite                 3.45.3               h091b4b1_0    conda-forge
libtiff                   4.5.1                h313beb8_0  
libwebp-base              1.3.2                h80987f9_0  
libzlib                   1.2.13               h53f4e23_5    conda-forge
llvm-openmp               14.0.6               hc6e5704_0  
lz4-c                     1.9.4                h313beb8_1  
mako                      1.2.3           py312hca03da5_0  
markdown-it-py            2.2.0           py312hca03da5_1  
markupsafe                2.1.3           py312h80987f9_0  
matplotlib-base           3.8.4           py312hd77ebd4_0  
mdurl                     0.1.0           py312hca03da5_0  
multimethod               1.9.1           py312hca03da5_0  
mypy_extensions           1.0.0           py312hca03da5_0  
ncurses                   6.5                  hb89a1cb_0    conda-forge
numexpr                   2.8.7           py312h0f3ea24_0  
numpy                     1.26.4          py312h7f4fdc5_0  
numpy-base                1.26.4          py312he047099_0  
openjpeg                  2.3.0                h7a6adac_2  
openpyxl                  3.1.2           py312h80987f9_0  
openssl                   3.3.0                h0d3ecfb_0    conda-forge
orderedmultidict          1.0.1              pyhd8ed1ab_1    conda-forge
packaging                 23.2            py312hca03da5_0  
pandas                    2.2.1           py312hd77ebd4_0  
pandera                   0.19.3               hd8ed1ab_0    conda-forge
pandera-base              0.19.3             pyhd8ed1ab_0    conda-forge
passlib                   1.7.4              pyhd3eb1b0_0  
pendulum                  2.1.2              pyhd3eb1b0_1  
phonenumbers              8.12.27            pyhd3eb1b0_0  
pillow                    10.3.0          py312h80987f9_0  
pint                      0.23               pyhd8ed1ab_0    conda-forge
pip                       24.0            py312hca03da5_0  
psycopg                   3.1.18          py312hfa0702a_0    conda-forge
psycopg-c                 3.1.18          py312h3db63bb_0    conda-forge
pyam                      2.2.2              pyhd8ed1ab_0    conda-forge
pybind11-abi              5                    hd3eb1b0_0  
pycparser                 2.21               pyhd3eb1b0_0  
pydantic                  2.5.3           py312hca03da5_0  
pydantic-core             2.14.6          py312hf0e4da2_0  
pydantic-settings         2.2.1              pyhd8ed1ab_0    conda-forge
pygments                  2.15.1          py312hca03da5_1  
pyjwt                     2.8.0           py312hca03da5_0  
pyparsing                 3.0.9           py312hca03da5_0  
pysocks                   1.7.1           py312hca03da5_0  
python                    3.12.3          h4a7b5fc_0_cpython    conda-forge
python-dateutil           2.9.0post0      py312hca03da5_0  
python-dotenv             1.0.1              pyhd8ed1ab_0    conda-forge
python-tzdata             2023.3             pyhd3eb1b0_0  
python_abi                3.12                    4_cp312    conda-forge
pytz                      2024.1          py312hca03da5_0  
pytzdata                  2020.1             pyhd3eb1b0_0  
pyyaml                    6.0.1           py312h80987f9_0  
readline                  8.2                  h1a28f6b_0  
requests                  2.31.0          py312hca03da5_1  
rich                      13.7.1             pyhd8ed1ab_0    conda-forge
scipy                     1.13.0          py312hfa28a95_0  
seaborn                   0.12.2          py312hca03da5_0  
setuptools                69.5.1          py312hca03da5_0  
shellingham               1.5.0           py312hca03da5_0  
six                       1.16.0             pyhd3eb1b0_1  
sniffio                   1.3.0           py312hca03da5_0  
sqlalchemy                2.0.25          py312h80987f9_0  
sqlalchemy-utils          0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-arrow    0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-babel    0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-base     0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-color    0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-encrypted 0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-intervals 0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-password 0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-pendulum 0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-phone    0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-timezone 0.41.2             pyhd8ed1ab_0    conda-forge
sqlalchemy-utils-url      0.41.2             pyhd8ed1ab_0    conda-forge
starlette                 0.27.0          py312hca03da5_0  
tk                        8.6.14               h6ba3021_0  
toml                      0.10.2             pyhd3eb1b0_0  
typeguard                 4.2.1           py312hca03da5_0  
typer                     0.9.0           py312hca03da5_0  
typing-extensions         4.11.0          py312hca03da5_0  
typing_extensions         4.11.0          py312hca03da5_0  
typing_inspect            0.9.0           py312hca03da5_0  
tzdata                    2024a                h04d1e81_0  
unicodedata2              15.1.0          py312h80987f9_0  
urllib3                   2.2.1           py312hca03da5_0  
wheel                     0.43.0          py312hca03da5_0  
wquantiles                0.6                pyhd8ed1ab_0    conda-forge
wrapt                     1.14.1          py312h80987f9_0  
xlsxwriter                3.1.1           py312hca03da5_0  
xz                        5.4.6                h80987f9_1  
yaml                      0.2.5                h1a28f6b_0  
zipp                      3.17.0          py312hca03da5_0  
zlib                      1.2.13               h53f4e23_5    conda-forge
zstd                      1.5.5                hd90d995_2  
@glatterf42
Copy link
Collaborator

Hi @jeff-ws, sorry for the late reply! Do you still face this issue or have you found a workaround?

If I understand this issue correctly, this is caused by pyam relying on ixmp4, which needs httpx, but with the http2 extra. Unfortunately, we use a pyproject.toml file to manage ixmp4, where we can list extras like this, which pip and similar tools can easily understand, but conda can't. Incidentally, this is one of the reasons we try to avoid it and I would recommend you do the same if at all possible.
If you want to use conda regardless, I think your only option is to keep installing missing packages until things work. In your case, the last line of the error message states that the packages h2 is missing. So you could go to conda forge and search for it and find the command to install it: conda install conda-forge::h2, to be run on an anaconda command line with your conda environment active.
Afterwards, this issue should be gone, but new ones might come up due to conda's limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants