NDAR / nda-tools

Python package for interacting with NDA web services. Used to validate, submit, and download data to and from NDA.
MIT License
48 stars 22 forks source link

Not able to use the downloadcmd #38

Closed kuhlaid closed 2 years ago

kuhlaid commented 2 years ago

Running into the following error trying to run downloadcmd -h

Running NDATools Version 0.2.10
Traceback (most recent call last):
  File "/home/me/.local/lib/python3.8/site-packages/requests/models.py", line 382, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 392, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
  File "<string>", line 2, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: https://pypi.org/pypi/nda-tools/json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/me/.local/bin/downloadcmd", line 5, in <module>
    from NDATools.clientscripts.downloadcmd import main
  File "/home/me/.local/lib/python3.8/site-packages/NDATools/__init__.py", line 42, in <module>
    check_version()
  File "/home/me/.local/lib/python3.8/site-packages/NDATools/__init__.py", line 22, in check_version
    req = requests.get(url_pattern.format(package=package))
  File "/home/me/.local/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/home/me/.local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/me/.local/lib/python3.8/site-packages/requests/sessions.py", line 528, in request
    prep = self.prepare_request(req)
  File "/home/me/.local/lib/python3.8/site-packages/requests/sessions.py", line 456, in prepare_request
    p.prepare(
  File "/home/me/.local/lib/python3.8/site-packages/requests/models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "/home/me/.local/lib/python3.8/site-packages/requests/models.py", line 384, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: https://pypi.org/pypi/nda-tools/json
gregmagdits commented 2 years ago

The url in the error message seems valid (browser returns a response without error), and I haven't seen this error before in either Mac or Windows machines. A quick google search showed that the requests library uses urllib3 to parse url's and that in some instances when running into this error, it can be resolved by running:

python -m pip install --upgrade urllib3

Please give that a shot and let us know if it resolves the issue.

kuhlaid commented 2 years ago

Thank you @gregmagdits, upgrading urllib3 fixed the issue.