Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why I receive ImportError: cannot import name 'just_fix_windows_console' from 'colorama'?

I have to use BayesianOptimization for hyper parameter tuning for neural networks, for the same when I’m importing it using, from bayes_opt import BayesianOptimization, the following error is obtained

`ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_28896\1719632484.py in <module>
----> 1 from bayes_opt import BayesianOptimization

~\anaconda3\lib\site-packages\bayes_opt\__init__.py in <module>
----> 1 from .bayesian_optimization import BayesianOptimization, Events
      2 from .domain_reduction import SequentialDomainReductionTransformer
      3 from .util import UtilityFunction
      4 from .logger import ScreenLogger, JSONLogger
      5 from .constraint import ConstraintModel

~\anaconda3\lib\site-packages\bayes_opt\bayesian_optimization.py in <module>
      3 from bayes_opt.constraint import ConstraintModel
      4 
----> 5 from .target_space import TargetSpace
      6 from .event import Events, DEFAULT_EVENTS
      7 from .logger import _get_default_logger

~\anaconda3\lib\site-packages\bayes_opt\target_space.py in <module>
      2 
      3 import numpy as np
----> 4 from .util import ensure_rng, NotUniqueError
      5 from .util import Colours
      6 

~\anaconda3\lib\site-packages\bayes_opt\util.py in <module>
      3 from scipy.stats import norm
      4 from scipy.optimize import minimize
----> 5 from colorama import just_fix_windows_console
      6 
      7 

ImportError: cannot import name 'just_fix_windows_console' from 'colorama' (C:\Users\saiga\anaconda3\lib\site-packages\colorama\__init__.py)
`
  • I have tried importing ‘colorama’, and other modules in it, which was working, but this name isn’t.
  • Also BayesianOptimization can be directly imported, using import BayesianOptimization but I need to call BayesianOPtimization in the program later using
gbm_bo = BayesianOptimization(gbm_cl_bo, params_gbm, random_state=111)

where gbm_cl_bo are functions defined. But then, the below given error is coming.

TypeError: 'module' object is not callable

So, inorder to avoid this I think I need to call BayesianOptimization from a parent directory. For the same I have also tried the following code : "from .BayesianOptimization import BayesianOptimization", but received the error as

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_28896\572044167.py in <module>
----> 1 from .BayesianOptimization import BayesianOptimization

ImportError: attempted relative import with no known parent package
  1. So how to fix the above import error?
  2. Otherwise, is there an alternate way of calling BayesianOptimization, so as not to get the error "’module’ object is not callable".

>Solution :

Based on the changelog for colorama, that function was added in the latest version of the library, 0.4.6.

Make sure you have that version installed, with e.g. pip install -U colorama.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading