diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

ImportError: cannot import name 'PROTOCOL_TLS' from 'urllib3.util.ssl_'

Open WASasquatch opened this issue 2 years ago • 3 comments

Describe the bug

When I import accelerate after installing it, and urllib3 (which was verified via urllib3.__version__) I get the following error only one time. When I run the cell again, the error is gone. Is there in order to these installations preferred?

[<ipython-input-2-14c74dad3ffb>](https://localhost:8080/#) in <module>
   1758 
   1759     import PIL
-> 1760     from accelerate import Accelerator
   1761     #from accelerate.logging import get_loggert
   1762     from accelerate.utils import set_seed

[/usr/local/lib/python3.7/dist-packages/accelerate/__init__.py](https://localhost:8080/#) in <module>
      5 __version__ = "0.13.0"
      6 
----> 7 from .accelerator import Accelerator
      8 from .big_modeling import cpu_offload, disk_offload, dispatch_model, init_empty_weights, load_checkpoint_and_dispatch
      9 from .launchers import debug_launcher, notebook_launcher

[/usr/local/lib/python3.7/dist-packages/accelerate/accelerator.py](https://localhost:8080/#) in <module>
     25 import torch
     26 
---> 27 from .checkpointing import load_accelerator_state, load_custom_state, save_accelerator_state, save_custom_state
     28 from .data_loader import prepare_data_loader
     29 from .logging import get_logger

[/usr/local/lib/python3.7/dist-packages/accelerate/checkpointing.py](https://localhost:8080/#) in <module>
     22 from torch.cuda.amp import GradScaler
     23 
---> 24 from .utils import (
     25     MODEL_NAME,
     26     OPTIMIZER_NAME,

[/usr/local/lib/python3.7/dist-packages/accelerate/utils/__init__.py](https://localhost:8080/#) in <module>
     96 from .launch import PrepareForLaunch, _filter_args, get_launch_prefix
     97 from .memory import find_executable_batch_size
---> 98 from .other import (
     99     extract_model_from_parallel,
    100     get_pretty_name,

[/usr/local/lib/python3.7/dist-packages/accelerate/utils/other.py](https://localhost:8080/#) in <module>
     19 import torch
     20 
---> 21 from ..commands.config.cluster import ClusterConfig
     22 from ..commands.config.config_args import default_json_config_file
     23 from ..state import AcceleratorState

[/usr/local/lib/python3.7/dist-packages/accelerate/commands/config/__init__.py](https://localhost:8080/#) in <module>
     23 from .config_args import cache_dir, default_config_file, default_yaml_config_file, load_config_from_file  # noqa: F401
     24 from .config_utils import _ask_field, _convert_compute_environment
---> 25 from .sagemaker import get_sagemaker_input
     26 
     27 

[/usr/local/lib/python3.7/dist-packages/accelerate/commands/config/sagemaker.py](https://localhost:8080/#) in <module>
     25 
     26 if is_boto3_available():
---> 27     import boto3  # noqa: F401
     28 
     29 

[/usr/local/lib/python3.7/dist-packages/boto3/__init__.py](https://localhost:8080/#) in <module>
     15 
     16 from boto3.compat import _warn_deprecated_python
---> 17 from boto3.session import Session
     18 
     19 __author__ = 'Amazon Web Services'

[/usr/local/lib/python3.7/dist-packages/boto3/session.py](https://localhost:8080/#) in <module>
     15 import os
     16 
---> 17 import botocore.session
     18 from botocore.client import Config
     19 from botocore.exceptions import DataNotFoundError, UnknownServiceError

[/usr/local/lib/python3.7/dist-packages/botocore/session.py](https://localhost:8080/#) in <module>
     24 import warnings
     25 
---> 26 import botocore.client
     27 import botocore.configloader
     28 import botocore.credentials

[/usr/local/lib/python3.7/dist-packages/botocore/client.py](https://localhost:8080/#) in <module>
     15 import warnings
     16 
---> 17 from botocore import waiter, xform_name
     18 from botocore.args import ClientArgsCreator
     19 from botocore.auth import AUTH_TYPE_MAPS

[/usr/local/lib/python3.7/dist-packages/botocore/waiter.py](https://localhost:8080/#) in <module>
     16 import jmespath
     17 
---> 18 from botocore.docs.docstring import WaiterDocstring
     19 from botocore.utils import get_service_module_name
     20 

[/usr/local/lib/python3.7/dist-packages/botocore/docs/__init__.py](https://localhost:8080/#) in <module>
     13 import os
     14 
---> 15 from botocore.docs.service import ServiceDocumenter
     16 
     17 

[/usr/local/lib/python3.7/dist-packages/botocore/docs/service.py](https://localhost:8080/#) in <module>
     12 # language governing permissions and limitations under the License.
     13 from botocore.docs.bcdoc.restdoc import DocumentStructure
---> 14 from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
     15 from botocore.docs.paginator import PaginatorDocumenter
     16 from botocore.docs.waiter import WaiterDocumenter

[/usr/local/lib/python3.7/dist-packages/botocore/docs/client.py](https://localhost:8080/#) in <module>
     12 # language governing permissions and limitations under the License.
     13 from botocore.compat import OrderedDict
---> 14 from botocore.docs.example import ResponseExampleDocumenter
     15 from botocore.docs.method import (
     16     document_custom_method,

[/usr/local/lib/python3.7/dist-packages/botocore/docs/example.py](https://localhost:8080/#) in <module>
     11 # ANY KIND, either express or implied. See the License for the specific
     12 # language governing permissions and limitations under the License.
---> 13 from botocore.docs.shape import ShapeDocumenter
     14 from botocore.docs.utils import py_default
     15 

[/usr/local/lib/python3.7/dist-packages/botocore/docs/shape.py](https://localhost:8080/#) in <module>
     17 # inherited from a Documenter class with the appropriate methods
     18 # and attributes.
---> 19 from botocore.utils import is_json_value_header
     20 
     21 

[/usr/local/lib/python3.7/dist-packages/botocore/utils.py](https://localhost:8080/#) in <module>
     32 import botocore
     33 import botocore.awsrequest
---> 34 import botocore.httpsession
     35 
     36 # IP Regexes retained for backwards compatibility

[/usr/local/lib/python3.7/dist-packages/botocore/httpsession.py](https://localhost:8080/#) in <module>
     20 from urllib3.exceptions import SSLError as URLLib3SSLError
     21 from urllib3.util.retry import Retry
---> 22 from urllib3.util.ssl_ import (
     23     DEFAULT_CIPHERS,
     24     OP_NO_COMPRESSION,

ImportError: cannot import name 'PROTOCOL_TLS' from 'urllib3.util.ssl_' (/usr/local/lib/python3.7/dist-packages/urllib3/util/ssl_.py)


---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Reproduction

No response

Logs

No response

System Info

  • diffusers version: 0.5.0.dev0
  • Platform: Linux-5.10.133+-x86_64-with-Ubuntu-18.04-bionic
  • Python version: 3.7.14
  • PyTorch version (GPU?): 1.12.1+cu113 (True)
  • Huggingface_hub version: 0.10.0
  • Transformers version: 4.22.2
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: Not sure what colab is doing

WASasquatch avatar Oct 06 '22 19:10 WASasquatch

@WASasquatch looks like you've resolved it? https://github.com/huggingface/diffusers/issues/756#issuecomment-1270571541

anton-l avatar Oct 06 '22 19:10 anton-l

@WASasquatch looks like you've resolved it? #756 (comment)

This wasn't, unfortunately. Still getting it on every install, but only first time around. After that, it appears to be able to import the 'missing' module just fine. I tried switching around the order of installs, even moving urllib3 before diffusers, transformers and accelerate. It was previously after diffusers, but before transformers.

WASasquatch avatar Oct 06 '22 19:10 WASasquatch

Thanks for the issue, but it doesn't seem to be related to diffuser, it seems to be coming from accelerate and then some sagemaker stuff. Could you please open an issue on accelerate repo

patil-suraj avatar Oct 07 '22 09:10 patil-suraj

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Nov 06 '22 15:11 github-actions[bot]

Note that for urllib3, I updated the py2neo package to fix it

dfaqw avatar Feb 11 '23 04:02 dfaqw