close

[Solved] ImportError: No module named ‘yaml’

Hello Guys, How are you all? Hope You all Are Fine. Today I am Just trying to run my script and I am facing following error ImportError: No module named ‘yaml’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ImportError: No module named ‘yaml’ Error Occurs ?

I am Just trying to run my script and I am facing following error.

 import yaml
 ImportError: No module named 'yaml'

How To Solve ImportError: No module named ‘yaml’ Error?

  1. How To Solve ImportError: No module named ‘yaml’ Error ?

    To Solve ImportError: No module named ‘yaml’ Error To solve this error all you need to do is just install pyyaml using this command. pip install pyyaml.

  2. ImportError: No module named ‘yaml’

    To Solve ImportError: No module named ‘yaml’ Error To solve this error all you need to do is just install pyyaml using this command. pip install pyyaml.

Solution 1: Install pyyaml

To solve this error all you need to do is just install pyyaml using this command.

pip install pyyaml

Solution 2: uninstall and then reinstall pyyaml

First of all you need to uninstall python-yaml and its dependencies with the help of this command.

sudo apt-get remove python3-yaml
sudo apt-get remove --auto-remove python3-yaml

Then Just Purge config/data too

sudo apt-get purge python3-yaml
sudo apt-get purge --auto-remove python3-yaml

Now reinstal pyyaml

sudo pip3 install pyyaml

Solution 3 : use virtualenv 

pip3 install virtualenv

Then

virtualenv --python=python3 venv

Now Activate

source venv/bin/activate

install pyyaml

pip install pyyaml
python env/common_config/add_imagepullsecret.py

Solution 3: Use this command

If you are using pip with python2 then run this command

pip install pyyaml

If you are using Python3 then run this

pip3 install pyyaml

If you are Linux user then run this command.

sudo pip3 install pyyaml

Try this Command for python2

python -m pip install pyyaml

For python3 Run this command.

python3 -m pip install pyyaml

Conda users run this command.

conda install -c conda-forge pyyaml

Conclusion

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment