tartley / colorama

Simple cross-platform colored terminal text in Python
BSD 3-Clause "New" or "Revised" License
3.58k stars 255 forks source link

'Colorama' has no attribute 'init' and has no attribute 'just_fix_windows_console' #385

Closed RParkerE closed 8 months ago

RParkerE commented 8 months ago

I am on Windows Version 10.0.19045.4046 using Python 3.7.16 with Colorama 0.4.6 installed in my anaconda environment with python 3.7. When trying to import an external library that uses colorama I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\pypose\__init__.py", line 3, in <module>
    from .lietensor import LieTensor, Parameter, SO3, so3, SE3, se3, Sim3, sim3, RxSO3, rxso3
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\pypose\lietensor\__init__.py", line 2, in <module>
    from .lietensor import LieTensor, Parameter
  File "C:\Users\user\anaconda3\envs\CARLA\lib\site-packages\pypose\lietensor\lietensor.py", line 3, in <module>
    import torch, warnings
  File "C:\Users\user\anaconda3\envs\CARLA\lib\site-packages\torch\__init__.py", line 884, in <module>
    from torch import hub as hub
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\torch\hub.py", line 20, in <module>
    from tqdm.auto import tqdm  # automatically select proper tqdm submodule if available
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\__init__.py", line 3, in <module>
    from .cli import main  # TODO: remove in v5.0.0
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\cli.py", line 9, in <module>
    from .std import TqdmKeyError, TqdmTypeError, tqdm
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\std.py", line 20, in <module>
    from .utils import (
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\utils.py", line 28, in <module>
    colorama.init(strip=False)
AttributeError: module 'colorama' has no attribute 'init'

I tried to edit the tqdm/utils.py file to use just_fix_windows_console() instead and get a similar issue:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\pypose\__init__.py", line 3, in <module>
    from .lietensor import LieTensor, Parameter, SO3, so3, SE3, se3, Sim3, sim3, RxSO3, rxso3
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\pypose\lietensor\__init__.py", line 2, in <module>
    from .lietensor import LieTensor, Parameter
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\pypose\lietensor\lietensor.py", line 3, in <module>
    import torch, warnings
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\torch\__init__.py", line 884, in <module>
    from torch import hub as hub
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\torch\hub.py", line 20, in <module>
    from tqdm.auto import tqdm  # automatically select proper tqdm submodule if available
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\__init__.py", line 3, in <module>
    from .cli import main  # TODO: remove in v5.0.0
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\cli.py", line 9, in <module>
    from .std import TqdmKeyError, TqdmTypeError, tqdm
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\std.py", line 20, in <module>
    from .utils import (
  File "C:\Users\usr\anaconda3\envs\CARLA\lib\site-packages\tqdm\utils.py", line 28, in <module>
    colorama.just_fix_windows_console(strip=False)
AttributeError: module 'colorama' has no attribute 'just_fix_windows_console'
RParkerE commented 8 months ago

Found a solution in another issue.

You have to import colorama using from colorama import initialise