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

intermine.webservice import Service error #2424

Open
AndreaFurlani opened this issue Mar 9, 2022 · 2 comments
Open

intermine.webservice import Service error #2424

AndreaFurlani opened this issue Mar 9, 2022 · 2 comments

Comments

@AndreaFurlani
Copy link

Using the last versions of Python it is no more possible to import the Service module of intermine, resulting in the following error:

Traceback (most recent call last): File "<ipython-input-3-b381508e45c3>", line 3, in <module> from UserDict import DictMixin File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) ModuleNotFoundError: No module named 'UserDict' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3251, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-3-b381508e45c3>", line 9, in <module> from collections import MutableMapping as DictMixin ImportError: cannot import name 'MutableMapping' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

In the webservice.py file the problems are the following:

  1. from urlparse import urlparse -> the library was moved inside urllib.parse
  2. from UserDict import DictMixin -> no more available, use MutableMapping instead
  3. from urllib import urlencode -> the library was moved inside urllib.parse

Modify the import section as follow solved the problem:
try: import sys from urllib.parse import urlparse, urlunparse, parse_qs, urlencode from collections.abc import MutableMapping as DictMixin from collections import OrderedDict from urllib.request import urlopen except ImportError: from urllib.parse import urlparse from urllib.parse import urlencode from .odict import OrderedDict from collections import MutableMapping as DictMixin from urllib.request import urlopen

Making these changes in the source code will no longer require the intervention of a user to modify it, as it is not possible in all cases.

@danielabutano
Copy link
Member

danielabutano commented Mar 11, 2022

Thanks @AndreaFurlani for your feedback and suggestions. At the moment the latest Python version supported is 3.7.

@fomightez
Copy link

fomightez commented Mar 6, 2024

This is what @AndreaFurlani posted, I believe (because editing the appropriate section in webservice.py worked in conjunction with Python 3.10), formatted correctly for easier pasting:

try:
    import sys
    from urllib.parse import urlparse, urlunparse, parse_qs, urlencode
    from collections.abc import MutableMapping as DictMixin
    from collections import OrderedDict
    from urllib.request import urlopen
except ImportError:
    from urllib.parse import urlparse
    from urllib.parse import urlencode
    from .odict import OrderedDict
    from collections import MutableMapping as DictMixin
    from urllib.request import urlopen

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

3 participants