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

AttributeError: module 'collections' has no attribute 'MutableMapping' #5469

Closed
mirodil1 opened this issue Nov 14, 2022 · 16 comments
Closed
Labels
Type: Question ❔ This is a question or a request for support.

Comments

@mirodil1
Copy link

I have a problem when using pipenv in ubuntu os.
Cannot use command pipenv, even for checking version

Searched for similar questions but not satisfied.

Ubuntu

Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy

Python

Python 3.10.6

Pipenv

pipenv version (11.9.0-1.1).


Traceback (most recent call last):
File "/usr/bin/pipenv", line 33, in <module>
  sys.exit(load_entry_point('pipenv==11.9.0', 'console_scripts', 'pipenv')())
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
  return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 696, in main
  with self.make_context(prog_name, args, **extra) as ctx:
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 621, in make_context
  self.parse_args(ctx, args)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 1018, in parse_args
  rest = Command.parse_args(self, ctx, args)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 875, in parse_args
  parser = self.make_parser(ctx)
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 821, in make_parser
  for param in self.get_params(ctx):
File "/usr/lib/python3/dist-packages/pipenv/vendor/click/core.py", line 774, in get_params
  help_option = self.get_help_option(ctx)
File "/usr/lib/python3/dist-packages/pipenv/cli.py", line 26, in get_help_option
  from .import core
File "/usr/lib/python3/dist-packages/pipenv/core.py", line 21, in <module>
  import requests
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/__init__.py", line 65, in <module>
  from . import utils
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/utils.py", line 27, in <module>
  from .cookies import RequestsCookieJar, cookiejar_from_dict
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/cookies.py", line 172, in <module>
  class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
@matteius
Copy link
Member

Do not install pipenv from apt, it's way too old. Install from pypi.

@mirodil1
Copy link
Author

@matteius Thanks.

@matteius matteius added the Type: Question ❔ This is a question or a request for support. label Nov 16, 2022
@oz123
Copy link
Contributor

oz123 commented Nov 19, 2022

This seems solved.

@oz123 oz123 closed this as completed Nov 19, 2022
@sentientmachine
Copy link

sentientmachine commented Dec 2, 2022

Downgrading the requests package to 2.13.0 and trying to import requests with python3.10 will produce the above error.

Another package presumptuously downgraded your requests package for its own needs, and now it's incompatible with whatever you're using it for now. Force it back up to date with something like:

pip3 install --user -Iv requests==2.28.1

@matteius
Copy link
Member

matteius commented Dec 2, 2022

@sentientmachine Especially applicable seeing as how your comment has nothing to do with this issue--the Ubuntu maintainers haven't bothered updating the apt repository in years, and we do not recommend user install from apt. That is where the source of this error originated from. If you could provide specific examples of how the contract is changing that you are unhappy with I would be happy to address. As far as some recent regressions, yeah there were a number of features from Hacktoberfets/October that caused some edge cases, many of which are already addressed. The ones that aren't are a priority for our two maintainers, myself and Oz. We both took on this project 1-year ago today and have made major strides towards its maintainability. There have been bumps along the way, that we are very proactive to responding to.

@matteius
Copy link
Member

matteius commented Dec 2, 2022

I am confused now. @sentientmachine are you saying that requests is broken in pipenv? What version of pipenv is having the issue? I am unaware of a change that affects python 3.10 minor versions ... the original poster had this issue because they installed a version of pipenv from 2018. We have had many releases of pipenv this year, many are quite good.

@sentientmachine
Copy link

The problem is outside of pipenv, I get it with:

$ pip3 install --user requests
$ python3.10
Python 3.10.8 (main, Oct 26 2022, 13:56:30) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/el/.local/lib/python3.10/site-packages/requests/__init__.py", line 63, in <module>
    from . import utils
  File "/home/el/.local/lib/python3.10/site-packages/requests/utils.py", line 29, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "/home/el/.local/lib/python3.10/site-packages/requests/cookies.py", line 174, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'

Downgrading to python3.8 fixes the problem:

$ python3.8 -m pip install --user requests
$ python3.8
Python 3.8.15 (default, Dec  2 2022, 12:56:52) 
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> print(requests.__path__)
['/home/el/.local/lib/python3.8/site-packages/requests']

The requests package does not seem to tolerate Python3.10 for some reason.

@matteius
Copy link
Member

matteius commented Dec 2, 2022

@mirodil1 I use requests with python 3.10 daily -- I think something else is at play. Can you verify what version of requests you have. Perhaps requests.__version__ ?

@matteius
Copy link
Member

matteius commented Dec 2, 2022

@sentientmachine that version is from 2017 -- you should be on requests==2.28.1

@sentientmachine
Copy link

@matteius A different python package downgraded my requests package without asking. I should keep a closer eye on that sort of thing next time.

@matteius
Copy link
Member

matteius commented Dec 2, 2022

Well with pipenv, you could specify the version of requests that you require, the version of the other packages, and the resolver will determine if that is even possible and it installs the resolved dependencies in an isolated way so that another package won't downgrade a different package specified in the lock file.

@mirodil1
Copy link
Author

mirodil1 commented Dec 5, 2022

@matteius I am using requests==2.25.1

@Sh0gunBR
Copy link

i,m using chatterbot, and im coding my bot and this erro appeared:
module 'collections' has no attribute 'MutableMapping'

@yomajo
Copy link

yomajo commented Feb 10, 2023

Do not install pipenv from apt, it's way too old. Install from pypi.

why is pipenv even in apt if it's out of date?

@matteius
Copy link
Member

None of the active maintainers (myself and @oz123 ) have access to the apt repository or knowledge of it.

@yomajo
Copy link

yomajo commented Feb 10, 2023

Got it. Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question ❔ This is a question or a request for support.
Projects
None yet
Development

No branches or pull requests

6 participants