Giter VIP home page Giter VIP logo

Comments (12)

shazow avatar shazow commented on May 21, 2024

Which version of Python are you using?
On Mar 27, 2012 5:50 AM, "MOON-CLJ" <
[email protected]>
wrote:

from urllib3 import HTTPSConnectionPool
File
"/usr/local/lib/python2.7/dist-packages/urllib3-1.3-py2.7.egg/urllib3/init.py",
line 22, in
from . import exceptions
ImportError: cannot import name exceptions

with easy_install


Reply to this email directly or view it on GitHub:
#65

from urllib3.

MOON-CLJ avatar MOON-CLJ commented on May 21, 2024

2.7

from urllib3.

shazow avatar shazow commented on May 21, 2024

Ah should have seen it in the path. I'm having trouble reproducing it though...

$ easy_install -U urllib3
Searching for urllib3
Reading http://pypi.python.org/simple/urllib3/
Reading https://github.com/shazow/urllib3
Reading http://code.google.com/p/urllib3/
Reading http://urllib3.readthedocs.org/
Best match: urllib3 1.3
Downloading http://pypi.python.org/packages/source/u/urllib3/urllib3-1.3.tar.gz#md5=6ae9acdaee2628b1c8b1de25b7e6c9da
Processing urllib3-1.3.tar.gz
Running urllib3-1.3/setup.py -q bdist_egg --dist-dir /var/folders/++/++7MiU++6+0++4RjPqRgNE+0K9c/-Tmp-/easy_install-RyJmpc/urllib3-1.3/egg-dist-tmp-MKXgRp
zip_safe flag not set; analyzing archive contents...
dummyserver.server: module references __file__
Adding urllib3 1.3 to easy-install.pth file

Installed /Users/shazow/env/urllib3/lib/python2.7/site-packages/urllib3-1.3-py2.7.egg
Processing dependencies for urllib3
Finished processing dependencies for urllib3

Any ideas?

from urllib3.

shazow avatar shazow commented on May 21, 2024

Ah, just noticed you meant the error happens on import, not install. Checking.

from urllib3.

shazow avatar shazow commented on May 21, 2024

Hmm, seems to work during import too:

$ python
Python 2.7.2 (default, Dec 16 2011, 19:20:09) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib3 import HTTPSConnectionPool
>>> import urllib3
>>> urllib3.exceptions
<module 'urllib3.exceptions' from '/Users/shazow/env/urllib3/lib/python2.7/site-packages/urllib3-1.3-py2.7.egg/urllib3/exceptions.pyc'>
>>>

from urllib3.

MOON-CLJ avatar MOON-CLJ commented on May 21, 2024

oh i know, i check this
it's just because i used eventlet.import_patched
urllib3 = eventlet.import_patched('urllib3')
from urllib3 import HTTPSConnectionPool

but with version 1.2.2 this will be fine

from urllib3.

shazow avatar shazow commented on May 21, 2024

Ah, that is indeed a problem. Any interest in fixing it? :)

I was hoping to have exceptions available under urllib3.exceptions without an extra import if possible.

from urllib3.

MOON-CLJ avatar MOON-CLJ commented on May 21, 2024

ok i'll try to do this

from urllib3.

MOON-CLJ avatar MOON-CLJ commented on May 21, 2024

clj@clj-laptop:~/dev$ sudo easy_install urllib3==1.2.2
Searching for urllib3==1.2.2
Best match: urllib3 1.2.2
Processing urllib3-1.2.2-py2.7.egg
urllib3 1.2.2 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/urllib3-1.2.2-py2.7.egg
Processing dependencies for urllib3==1.2.2
Finished processing dependencies for urllib3==1.2.2
clj@clj-laptop:~/dev$ python
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import eventlet
urllib3 = eventlet.import_patched('urllib3')
from urllib3 import exceptions
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name exceptions

after viewing the source code of eventlet
i think this is just a eventlet.import_patched bug(as shown above)
but i still dont know exactly where is the bug in eventlet
i'll check it again later

if you have times, you can check this
https://bitbucket.org/which_linden/eventlet/src/a60be8a9cdb5/eventlet/patcher.py

if you find what causes this,
please let me know
thanks in advance

from urllib3.

MOON-CLJ avatar MOON-CLJ commented on May 21, 2024

urllib3 version 1.2.2

Python 2.7.2+ (default, Oct  4 2011, 20:03:08) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import eventlet
>>> urllib3 = eventlet.import_patched('urllib3')
>>> dir(urllib3)
['HTTPConnectionPool', 'HTTPError', 'HTTPResponse', 'HTTPSConnectionPool', 'MaxRetryError', 'PoolManager', 'ProxyManager', 'SSLError', 'TimeoutError', '__author__', '__builtins__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__', '_collections', 'connection_from_url', 'connectionpool', 'encode_multipart_formdata', 'exceptions', 'filepost', 'get_host', 'make_headers', 'packages', 'poolmanager', 'proxy_from_url', 'request', 'response']
>>> import urllib3
>>> dir(urllib3)
['HTTPConnectionPool', 'HTTPError', 'HTTPResponse', 'HTTPSConnectionPool', 'MaxRetryError', 'PoolManager', 'ProxyManager', 'SSLError', 'TimeoutError', '__author__', '__builtins__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__', 'connection_from_url', 'encode_multipart_formdata', 'get_host', 'make_headers', 'proxy_from_url']

after import urllib3
some attributes were lost

from urllib3.

shazow avatar shazow commented on May 21, 2024

Hmm, here's the set difference:

['_collections',
 'request',
 'connectionpool',
 'filepost',
 'poolmanager',
 'exceptions',
 'packages',
 'response']

from urllib3.

MOON-CLJ avatar MOON-CLJ commented on May 21, 2024

it's not necessary to use eventlet.import_patched('urllib3')(but the bug is existed exactly)
eventlet.patcher.monkey_patch() can patch all the modules that eventlet can provide
so
eventlet.patcher.monkey_patch()
import urllib3
it will work for me

from urllib3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.