druid-io / pydruid

A Python connector for Druid
Other
506 stars 194 forks source link

AttributeError: module 'urllib' has no attribute 'error' #228

Open yingbo opened 4 years ago

yingbo commented 4 years ago

I got this error:

AttributeError: module 'urllib' has no attribute 'error'

I think in the client.py we should import urllib.request other than import urllib, in python 3.7 and python 3.8 at least, but I'm not sure how to fix it to make it works on all python versions.

eden-wang commented 4 years ago

I encountered the same problem in python 3.6.9, mac

eden-wang commented 4 years ago

wired, I created another venv, and it works now...

yingbo commented 4 years ago

@eden-wang You can check the client.py file to see what it's importing. I'm not sure starting which python 3 version, it requires to import urllib.request

eden-wang commented 3 years ago

@eden-wang You can check the client.py file to see what it's importing. I'm not sure starting which python 3 version, it requires to import urllib.request

It is import urllib.request

yingbo commented 3 years ago

Just checked it's still import urllib: https://github.com/druid-io/pydruid/blob/master/pydruid/client.py

sub007 commented 3 years ago

It requires import urllib.error to be imported explicitly.

yingbo commented 3 years ago

Looks this issue was fixed already. I'll close this.

lokkju commented 3 years ago

client.py still seems to have import urllib; where do you see it as fixed?

yingbo commented 3 years ago

Hi @lokkju , From their latest release: https://github.com/druid-io/pydruid/blob/pydruid-0.5.2/pydruid/client.py#L22, you can see from six.moves import urllib. The six.moves fixed the problem

sub007 commented 3 years ago

@yingbo : The code you are referring to is 0.5.2. Isn't master or 0.6 the latest release? They both have import urllib https://github.com/druid-io/pydruid/blob/master/pydruid/client.py#L18

jccardonar commented 3 years ago

I experienced this and fixed it by explicitly adding urllib.error (then later urllib.request) to client.py (thanks @sub007 ).

However, it was funny that running the script in ipython did not raise any exceptions. Anybody knows why?

yingbo commented 3 years ago

I have no idea either how the problem was fixed, or even being fixed. Hope the pydruid team can give us an answer.

gitmstoute commented 3 years ago

I encountered this error as well! Per the others, adding import urllib.error and import urllib.request to site-packages/pydruid/client.py of my virtualenv resolved the issue.

daymos commented 2 years ago

It was fixed in versin 5.2. However is broken again in 6. I managed to run this by installing 5.2. However this is an odd one, as I only had the problem while running it inside a docker container. Locally 6. works alright.

Mihaylov93 commented 1 year ago

Looks like with Python 3.9.10 pydruid==0.6.2, urllib3==1.26.12 the AttributeError: module 'urllib' has no attribute 'error' isn't produced anymore for me.

just-maiyak commented 1 year ago

Looks like I still have this issue with the 3.11 CPython interpreter and pydruid 6.5. What's interesting is that I don't have this issue when using IPython. My workaround for now is to explicitely import urllib.error and urllib.request in my script.

matkalinowski commented 11 months ago

This issue still occurs for versions: Python 3.10.7

Explicitly importing urllib.request in script solves it.