importerror: cannot import name ‘config’ from ‘decouple’ ( Solved )

importerror_ cannot import name 'config' from 'decouple' ( Solved )

importerror: cannot import name ‘config’ from ‘decouple’ error mostly occurs because of a simple confusion between decouple and python-decouple package. Most of the time developers or Data scientists use decouple package instead of a python-decouple. Because of this ambiguity, They face this error. Anyways in this article, we will understand the background for the use cases of these two modules. Accordingly, we will see the fixes for these errors.

Importerror: cannot import name ‘config’ from ‘decouple’ (Cause and Fix ) –

The cause is pretty clear for this error is misplacing the package decouple and python-decouple both. The simple way to fix this error is by uninstalling this decouple package and after that installing python-decouple package.

Step 1: Uninstall the package decouple –

Here is the command to uninstall the decouple package. You can use the pip package manager for this as well.

pip uninstall decouple

 

However, the next step after uninstalling this decouple package is installing the required package.

Step 2: Installing package python-decouple

The right package is python-decouple. Lets install the same with pip only. Here is the command to install python-decouple package.

importerror cannot import name 'config' from 'decouple'
importerror cannot import name ‘config’ from ‘decouple’
pip install python-decouple

Other Alternative to install python-decouple package-

In addition just similar to the pip package manager, There is conda package manager which we can use to install this python-decouple module. You may use any of the below conda command to achieve the same.

conda install -c conda-forge python-decouple
conda install -c conda-forge/label/gcc7 python-decouple
conda install -c conda-forge/label/cf201901 python-decouple
conda install -c conda-forge/label/cf202003 python-decouple

 

Why do we use python-decouple package ?

Above all, This python-decouple package is really providing the functionality to change the run-time parameters with redeploying the applications. I mean it helps in-

  • Saving parameters into .ini or .env extension files which do not need new deployment.
  • Converting Data Types
  • Uniform config for all instances and many more other functionalities.

In other words, it works as a layer between code and setting credentials.

In conclusion,  I hope now we have good background to fix this error. Please provide your feedback on the same.

Thanks
Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner