0

i create a function that dowload a file from a site in a certain directory

Use: download(url, dir)

but it not run the code is this:

import requests


def download(url: str, dir: str):
    print(f"Dowloading file to '{url}' in '{dir}'...")
    r=requests.get(url, allow_redirects=True)

    open(dir, "wb").write(r.content)
    print("Dowload complete!")

the error is this:

PS XXX> py tools/download.py
Traceback (most recent call last):
  File "XXX\download.py", line 1, in <module>
    import requests
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 63, in <module>
    from . import utils
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 27, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "C:\Users\XXX\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 172, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'

sorry for bad english

Tommy
  • 1

1 Answers1

1

I do believe that this is the package version issue, that was already discussed and resolved by these answers here:

https://stackoverflow.com/a/72607663/11724813

or

https://stackoverflow.com/a/71902541/11724813

Kokokoko
  • 452
  • 1
  • 8
  • 19