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: 'NoneType' object has no attribute 'groups' #291

Closed
benscarlson opened this issue Jan 10, 2024 · 23 comments · Fixed by #295
Closed

AttributeError: 'NoneType' object has no attribute 'groups' #291

benscarlson opened this issue Jan 10, 2024 · 23 comments · Fixed by #295
Labels
bug for issue

Comments

@benscarlson
Copy link

Provide environment information

/Users/benc/.pyenv/shims/python
Python 3.10.6
gdown 4.7.1

What OS are you using?

macOS Ventura 13.1 (M1)

Describe the Bug

Traceback (most recent call last):
File "/Users/benc/.pyenv/versions/3.10.6/bin/gdown", line 8, in
sys.exit(main())
File "/Users/benc/.pyenv/versions/3.10.6/lib/python3.10/site-packages/gdown/cli.py", line 143, in main
filenames = download_folder(
File "/Users/benc/.pyenv/versions/3.10.6/lib/python3.10/site-packages/gdown/download_folder.py", line 303, in download_folder
filename = download(
File "/Users/benc/.pyenv/versions/3.10.6/lib/python3.10/site-packages/gdown/download.py", line 259, in download
filename_from_url = m.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

Expected Behavior

It should download the folder

To Reproduce

This is accessing a folder with many large files. I'm sorry the folder can't be shared publically.

@benscarlson benscarlson added the bug for issue label Jan 10, 2024
@ydaniels
Copy link

I can also confirm this issue
seems content_disposition does not contain filename so regex failed. Failing back to filename_from_url = osp.basename(url)
for now

@tmorshed
Copy link

tmorshed commented Jan 10, 2024

Can confirm that this error arose for us today as well - three different computers (two sessions on GitHub Codespaces and a local computer). gdown version = 4.7.1

Hot fix: Downgrading to 4.6.1 fixes it:

pip install gdown==4.6.1

@Bremma
Copy link

Bremma commented Jan 10, 2024

Also seeing the same issue with gdown 4.7.1. Used last week without issue on Cygwin via Windows, but now getting the none type error noted above

@ILG2021
Copy link

ILG2021 commented Jan 10, 2024

Same problem, maybe google changed something to block gdown.

@KristjanRanna
Copy link

Same problem, maybe google changed something to block gdown.

How would it make any sense for them to decide to block gdown?

But yeah, I am getting the same error.

@Dharisd
Copy link

Dharisd commented Jan 11, 2024

same issue, was relying on this

@Randl
Copy link

Randl commented Jan 11, 2024

import gdown
url = "https://drive.google.com/file/d/1jjJ8k3L-BzFKSevoGo6yaJ-jCjc2SCK1/view"
filename = gdown.download(url, quiet=False, fuzzy=True)

When I run the code from jupyter notebook, I get Content-Disposition:
attachment; filename="clean_battle_anony_20240109.json"
but when I run from file, I get
attachment; filename="clean_battle_anony_20240109.json"; filename*=UTF-8''clean_battle_anony_20240109.json
so it crashes only from jupyter.

josephvusich added a commit to josephvusich/gdown that referenced this issue Jan 11, 2024
@awisbay
Copy link

awisbay commented Jan 11, 2024

yes me too, currently face the same issue. Yesterday still working.

vatanaksoytezer added a commit to vatanaksoytezer/gdown that referenced this issue Jan 11, 2024
@alirezaAsadi2018
Copy link

alirezaAsadi2018 commented Jan 11, 2024

Same problem here. I use google colab and get this error:

Traceback (most recent call last):
  File "/usr/local/bin/gdown", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/gdown/cli.py", line 156, in main
    filename = download(
  File "/usr/local/lib/python3.10/dist-packages/gdown/download.py", line 259, in download
    filename_from_url = m.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

My gdown version is the latest: v4.7.1.

Quick Fix:

I found out that versions above and equal to v4.6.4 are facing this probem but v4.6.3 is working fine. so all you need to do as a user is to downgrade your version:
pip install gdown==v4.6.3

@guesalomon
Copy link

I had this issue and also a permission error (“file is not public”). I believe both are connected to the removal of the headers:
headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36" # NOQA }

I readded them to the latest version and it fixed both issues.

@ericspod
Copy link

This does appear to be an issue of a hard-coded assumption about the format of the Content-Disposition header entry which has changed. We've encountered the problem inside and outside notebooks.

@ILG2021
Copy link

ILG2021 commented Jan 11, 2024

Hello, why the developer still don't fix it, gdown is widely used.

@Gesthub
Copy link

Gesthub commented Jan 11, 2024

@guesalomon Where should I add them?

@guesalomon
Copy link

@guesalomon Where should I add them?

You can add it on the line 153 of the download.py file:

res = sess.get(url, stream=True, verify=verify)

change to:

headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"  # NOQA } 

res = sess.get(url, stream=True, headers=headers, verify=verify)
    )

@ghunkins
Copy link

Quick Fix:

I found out that versions above and equal to v4.6.4 are facing this probem but v4.6.3 is working fine. so all you need to do as a user is to downgrade your version: pip install gdown==v4.6.3

The above fixed it for me. Just downgrade the package to v4.6.3 for now!

pip install gdown==v4.6.3

@guesalomon
Copy link

It worked for me also downgrading the version, but I was just giving the author a hint on what fixed it for me!

@Gesthub
Copy link

Gesthub commented Jan 11, 2024

@guesalomon Thank you.

@ghost
Copy link

ghost commented Jan 12, 2024

i also face the same issue, but downgrading gdown version is working fine

@mikel-brostrom
Copy link

Same issue here:

File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/gdown/download.py", line 248, in download
    filename_from_url = m.groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'

Downgrading the package to v4.6.3 solved it for me 😄

ericspod pushed a commit to Project-MONAI/MONAI that referenced this issue Jan 12, 2024
Workaround for #7382 #7383

### Description

Based on the comment
[here](wkentaro/gdown#291 (comment)),
pin the gdown version as a workaround. Will review this one once gdown
has some update internal.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
@rmcpantoja
Copy link

Hi @wkentaro and all,
I've fixed these two bugs in #293.

@wkentaro
Copy link
Owner

wkentaro commented Jan 16, 2024

Hey guys. Sorry for being late (I missed the notifications), but this should be fixed now via #295 and the latest release.

@Bremma
Copy link

Bremma commented Jan 16, 2024

v4.7.3 fixed the issue for me! Thank you wkentaro and everyone else who figured out the issue!

marksgraham pushed a commit to marksgraham/MONAI that referenced this issue Jan 30, 2024
Workaround for Project-MONAI#7382 Project-MONAI#7383

### Description

Based on the comment
[here](wkentaro/gdown#291 (comment)),
pin the gdown version as a workaround. Will review this one once gdown
has some update internal.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Mark Graham <markgraham539@gmail.com>
@clydebailey
Copy link

Hello, why the developer still don't fix it, gdown is widely used.

Please be respectful of the people who built a software that is widely used

juampatronics pushed a commit to juampatronics/MONAI that referenced this issue Mar 25, 2024
Workaround for Project-MONAI#7382 Project-MONAI#7383

### Description

Based on the comment
[here](wkentaro/gdown#291 (comment)),
pin the gdown version as a workaround. Will review this one once gdown
has some update internal.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
Yu0610 pushed a commit to Yu0610/MONAI that referenced this issue Apr 11, 2024
Workaround for Project-MONAI#7382 Project-MONAI#7383

### Description

Based on the comment
[here](wkentaro/gdown#291 (comment)),
pin the gdown version as a workaround. Will review this one once gdown
has some update internal.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
tbaudier added a commit to openspyrit/spyrit that referenced this issue May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug for issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.