opencobra/cobrapy

installation issue on v0.26.2

hariszaf opened this issue · 9 comments

I am trying to install latest cobrapy (v.0.26.2) .

After a successful pip install on a conda env with python3.10
when I try to import it I keep getting the following:

Python 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:24:10) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cobra
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/cobra/__init__.py", line 17, in <module>
    from cobra import io
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/cobra/io/__init__.py", line 9, in <module>
    from cobra.io.web import AbstractModelRepository, BiGGModels, BioModels, load_model
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/cobra/io/web/__init__.py", line 7, in <module>
    from .load import load_model
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/cobra/io/web/load.py", line 29, in <module>
    Cobrapy(),
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/cobra/io/web/cobrapy_repository.py", line 36, in __init__
    super().__init__(url="file:////", **kwargs)
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/cobra/io/web/abstract_model_repository.py", line 55, in __init__
    self._url = httpx.URL(url=url)
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/httpx/_urls.py", line 113, in __init__
    self._uri_reference = urlparse(url, **kwargs)
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/httpx/_urlparse.py", line 252, in urlparse
    validate_path(path, has_scheme=has_scheme, has_authority=has_authority)
  File "/home1/haris/.conda/envs/dnn/lib/python3.10/site-packages/httpx/_urlparse.py", line 367, in validate_path
    raise InvalidURL(
httpx.InvalidURL: URLs with no authority component cannot have a path starting with '//'

Same happens with v0.26.0.

When I try for v0.24.0 everything works fine. Any ideas why?

Yep, getting same issue! Just started today I believe

Just started today I believe

That's a relief to me as I would go nuts if it were from my side.. 😃

@cdiener I think the issue stems from the httpx package which just released version 0.24 about 5 hours ago. If I downgrade to httpx==0.23.3, it seems to fix the issue.

Yep that is a bug and is indeed related to https 0.24 not requiring escape of forward slashes anymore. I'll submit a fix.

Thanks for catching this! I was trying to lead my class through installation of cobrapy yesterday (bad timing I know) and we ran into this issue. I can see that the new release will fix this issue, but when will that new release be made available? Sorry I don't know how long it takes for updates to get out there.

@NathanGuy14 sorry for being trivial, but you can always use a previous version.
For me it worked with version v0.24.0

pip install cobra==0.24.0

@NathanGuy14 Yeah, I think will make a release today because that is affecting all new installs. It will also work fine if you keep httpx<0.24. So pip install cobra "httpx<0.24" should also work for now.

Fixed in cobrapy 0.26.3

This works! Thank you both! And thank you for the "trivial" suggestion - it really did help!